Streaming API Notifications Sent in Reverse Order Within a Transaction

In general, event notifications are delivered in the order of record changes. One exception is that when a record triggers multiple notifications within the same transaction, the last notifications are delivered first.

For example, let’s say you have a PushTopic for insertions and updates of contact records, and the PushTopic query selects fieldA. If a contact is inserted and then an Apex trigger or workflow updates fieldA in the same transaction, the order of notifications sent is:

  • Notification for the update of fieldA
  • Notification for the insertion of the record

In this case, the order of notifications depends on the order in which the Lightning Platform commits transactions.