You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Idempotency ensures that multiple publishes of the same message cannot result in duplicate messages.
937
937
938
-
It is possible that a client publishing a message using the REST interface may not receive acknowledgement of receipt from Ably, due to issues such as network failure outside of Ably's control. Clients will internally attempt to re-publish messages in these instances.
939
-
940
938
When idempotent publishing is enabled, the Ably SDK will internally assign a unique ID to each message which ensures that subsequent retry attempts cannot result in duplicate messages. Idempotent publishing is enabled by default in all latest Ably SDKs. It can be disabled by setting the @idempotentRestPublishing@ "@ClientOptions@":/docs/api/rest-sdk#client-options to @false@.
941
939
942
-
Note that Ably can only detect duplicate messages within a 2-minute window after the original message, with the same ID, is published. If a message with the same ID is published after this 2-minute window, it will be treated as a new message.
940
+
In some cases you may wish to set the unique message ID yourself to achieve idempotency, such as:
943
941
944
-
You can also specify message IDs externally. The following is an example of how you might do this:
942
+
* To ensure idempotency when a publisher instance might be restarted, and continuous activity cannot be guaranteed.
943
+
* To integrate with an upstream system that uses message IDs, to ensure idempotency across an entire message processing pipeline.
If setting your own message IDs be aware of the "restrictions":https://faqs.ably.com/client-specified-message-id-restrictions-for-multiple-messages-published-atomically on its format when publishing messages atomically.
946
+
947
+
<aside data-type='note'>
948
+
<p>Ably can only detect duplicate messages within a 2-minute window after the original message, with the same ID, is published. If a message with the same ID is published after this 2-minute window, it will be treated as a new message.</p>
949
+
</aside>
950
+
951
+
The following is an example of specifying message IDs yourself when publishing:
952
+
953
+
```[realtime_javascript]
954
+
const realtime = new Ably.Realtime = '{{API_KEY}}';
If manually specifying message IDs, it is important to be aware of how messages are published when calling the "publish()":/docs/api/rest-sdk/channels#publish method with an array of messages. See this "FAQ":https://faqs.ably.com/client-specified-message-id-restrictions-for-multiple-messages-published-atomically for further information.
1073
+
```[rest_swift]
1074
+
let rest = ARTRest(key: "{{API_KEY}}")
1075
+
var channel = rest.channels.get("{{RANDOM_CHANNEL_NAME}}")
0 commit comments