Skip to main content

Republish

If a client fails to receive a message NotificationMessage due to network packet loss, republish have the server resend it from the cache:

public Enums.StatusCode republish(int retransmitSequenceNumber);
Generally, there is no need to call this.

Under normal circumstances, it is AutoPublish handled internally SDK SequenceNumber Ack, and the client is not affected. This is used only API in special scenarios (active packet recovery / debugging).

When to Use​

  • The client detected SequenceNumber a gap and actively filled it.
  • After a temporary network outage, I want to retrieve the data from that period.
  • Debugging Phase / Testing SDK Republish Behavior

Usage​

import com.darra.opcua.*;

Enums.StatusCode st = sub.republish(12345);
if (st == Enums.StatusCode.Good) {
System.out.println("Server confirmed retransmit, data will arrive in next Publish");
} else {
System.out.println("Republish failed: " + st);
}

Note​

  • The server caches only the most recent N records ( NotificationMessage typically N = 10); any records beyond that cannot be retrieved.
  • republish This is a request to the server to "resend on the next publish," not to retrieve the data directly.
  • Resent data is handled via the normal callback onDataChanged; the client does not need to take any special action.
  • Error code BadMessageNotAvailable indicates that the SequenceNumber has exceeded the cache limit. It is a standard OPC UA server code, SDK Enums.StatusCode This constant has not been registered., cannot be written as Enums.StatusCode.BadMessageNotAvailable.sub.republish() The return value is only subject to a rough check Enums.StatusCode.fromCode(int); unregistered codes are all assigned to Enums.StatusCode.Bad, and cannot be distinguished from other Bad codes; for an accurate determination, compare the original int code (in the exception-throwing path, the original code is in OpcUaException.rawCode)

Difference from transferSubscriptions​

APIMeaning
republishThe server remembers the subscription; it's just that one message was missed.
transferSubscriptionsTaking Over the Subscriptions of the Old Session After a Session Reconnection

For more information, see Session Overview.

Next Step​