Republish
If a client fails to receive a message NotificationMessage due to network packet loss, Republish have the server resend it from the cache:
Status Republish(uint32_t retransmit_sequence_number);
Generally, there is no need to call it.
Its main API value isTrigger the server to resend the notification from the cache. Current implementationShow only the top-level service_result, The returned data is not parsed NotificationMessage; the actual data is still received during the next normal publish.
When to Use
- I've already obtained the specific details from elsewhere (logs / server diagnostics) SequenceNumberand would like the server to resend them.
- After a temporary network outage, I want the server to resend the cache entries from that time period.
- Debugging / Testing Server Behavior Republish
Not available at this time SequenceNumber
SDKNot doing it Line break detection—and it doesn't expose SequenceNumber it to the upper layer either:
- Publish requests are sent consistently 0 Ack
- The data in PublishResponse is
SequenceNumberparsed and then discarded; it is not sent back to the user. TransferSubscriptionsThe returned value is alsoAvailableSequenceNumbersparsed and then discarded; the current value is not exposed to the upper layer for SDK the time being.
Therefore, the information needed API can currently retransmit_sequence_number only be obtained through server-side or C-layer diagnostics.
Usage
auto st = sub.Republish(/*retransmit_sequence_number=*/12345);
if (st == Status::Good) {
std::cout << "Server accepted Republish; data arrives via the next Publish\n";
} else {
std::cout << "Republish failed: 0x" << std::hex << static_cast<uint32_t>(st) << "\n";
}
Note
- The return value is
Status, which is a strongly typed wrapper for a 32-bit status code. The server may returnenum class StatusInsideNo separate name the code (for example, the message has exceeded the server's retransmission queue), At this point, you can simplyst == Status::Gooddetermine whether it's valid or not; it depends on the specific code being used.static_cast<uint32_t>(st)+Stack::StatusName(...), Don't look for enumeration values that don't exist - The server caches only the most recent few entries ( NotificationMessage the queue length is determined by the server); any entries beyond that cannot be retrieved.
- Resent data is received via the normal data callback (
OnDataChange), and the client does not need to take any special action.
Difference from TransferSubscriptions
| API | Meaning |
|---|---|
| sub.Republish(seq_no) | The server remembers the subscription; it's just that one message was missed. |
| s.TransferSubscriptions(...) | Taking Over the Subscriptions of the Old Session After a Session Reconnection |
For more information, see Session Overview.