Newer Version Available

This content describes an older version of this product. View Latest

PushTopic Notification Message Order

PushTopic Notification Message Order with API Version 37.0 and Later

In API version 37.0 and later, Salesforce stores PushTopic notification messages temporarily in the event bus. Before a PushTopic notification message is stored, Salesforce assigns it a replay ID value. Subscribers receive notification messages from the event bus in the order of the replay ID. In general, PushTopic message notification order is the same as the transactions corresponding to the record changes that are committed in Salesforce. One exception is when a record triggers multiple notifications within the same transaction, the last notification is delivered first. For more information, see Streaming API Notifications Sent in Reverse Order Within a Transaction.

This example shows two PushTopic notification messages for two new invoice statements. INV-0001 is created before INV-0002 and its replayId value is lower.

1{
2  "data": {
3    "event": {
4      "createdDate": "2021-08-05T17:49:08.990Z",
5      "replayId": 2,
6      "type": "created"
7    },
8    "sobject": {
9      "Description__c": "New invoice statement #2",
10      "Id": "a02RM00000013VrYAI",
11      "Status__c": "Open",
12      "Name": "INV-0002"
13    }
14  },
15  "channel": "/topic/InvoiceStatementUpdates"
16}
17
18{
19  "data": {
20    "event": {
21      "createdDate": "2021-08-05T17:33:48.324Z",
22      "replayId": 1,
23      "type": "created"
24    },
25    "sobject": {
26      "Description__c": "New invoice statement",
27      "Id": "a02RM00000013VmYAI",
28      "Status__c": "Open",
29      "Name": "INV-0001"
30    }
31  },
32  "channel": "/topic/InvoiceStatementUpdates"
33}
No content provided

PushTopic Notification Message Order with API Version 36.0 and Earlier

In API version 36.0 and earlier, changes to data in your organization happen sequentially. But the order of the PushTopic event notification messages that you receive isn’t guaranteed. On the client side, you can use createdDate to order the notification messages returned in a channel. The value of createdDate is a UTC date/time value that indicates when the event occurred.

This example shows two PushTopic notification messages for two new invoice statements. INV-0001 is created before INV-0002 and its createdDate value is lower than the one for INV-0002.

1{
2  "data": {
3    "event": {
4      "createdDate": "2013-05-10T18:16:19.000+0000",
5      "type": "created"
6    },
7    "sobject": {
8      "Description__c": "New invoice statement #2",
9      "Id": "a00D0000008pvxcIAA",
10      "Status__c": "Open",
11      "Name": "INV-0002"
12    }
13  },
14  "channel": "/topic/InvoiceStatementUpdates"
15}
16
17{
18  "data": {
19    "event": {
20      "createdDate": "2013-05-10T18:15:11.000+0000",
21      "type": "created"
22    },
23    "sobject": {
24      "Description__c": "New invoice statement #1",
25      "Id": "a00D0000008pvzdIAA",
26      "Status__c": "Open",
27      "Name": "INV-0001"
28    }
29  },
30  "channel": "/topic/InvoiceStatementUpdates"
31}