Skip to main content

Consider a scenario where a transaction with the key "00000a82-7f3f-1c17-2bd3-7c636bd96311" is initiated. The transaction involves creating a case followed by creating an email message. Salesforce commits changes and begins sending CDC(Change Data Capture) events. But what happens if an internal error occurs while sending a CDC for the email message? Salesforce will send a gap create event for this change, raising two key questions:

  1. Will the gap event also have the same transaction key "00000a82-7f3f-1c17-2bd3-7c636bd96311," or will it be assigned a different transaction key?
  2. Will the order of the change events be maintained, meaning the first CDC event will be the create event for the case followed by the gap event for the email message, or can these events be disordered?
1 Antwort
  1. 4. Apr., 16:35

    Hi Marco, 

    Great questions about CDC Gap Event behavior. Here are the answers based on Salesforce documentation: 

    Question 1 - Transaction Key on Gap Events: 

    Yes, the gap event WILL retain the same transaction key as the original failed transaction. According to the Salesforce CDC documentation, a gap event is created when Salesforce cannot deliver a change event due to an internal error. The gap event is part of the same logical transaction and inherits the same transactionKey value as the events in that transaction. This allows subscribers to identify which transaction had the gap and correlate it with the records affected. 

    Question 2 - Event Ordering: 

    CDC events within the same transaction ARE ordered. Salesforce guarantees that change events within a single transaction are delivered in the order they occurred. In your scenario, the create event for the Case would be delivered first, followed by the gap event for the EmailMessage (since that was the record that caused the internal error). The events will not be disordered within the same transactionKey. 

    Important nuance: The gap event does NOT contain the actual changed field values. It only signals that a change occurred for that record but the full event data could not be delivered. Your subscriber should treat a gap event as a signal to re-query or re-sync the affected record(s) from Salesforce directly. 

    In summary: Same transactionKey, ordered within the transaction, but the gap event payload itself lacks field change details -- you need to query the affected object to get the current state. 

    Mani G | Principal/Founder | https://Keneland.com

0/9000