Overflow Events in Change Data Capture

The Salesforce team in their Developer Guide has explained the reasons for the generation of GAP_OVERFLOW events. The Developer Guide also mentions that these events won’t carry any actual record Ids and a Dummy record Id will be sent in these events:

Developer Guide.

My question is about how do we replicate the changes for these events if we don’t receive the record Ids in the event? What’s Salesforce’s preferred strategy to replicate the changes corresponding to these events?


This is a very usual scenario, you have to write a little bit of workaround for this.

You know the timestamp of last change before overflow event, use that timestamp to get all the updated and deleted records for the given sObject type.

getUpdated() and getDeleted() are part of Data Replication API which was before CDC, given that CDC has its own set of limitation, you have to come up with a mashup of CDC and DataReplication API.

UPDATE: There might be a workaround possible if you can ditch CDC and use standard platform event.

Instead of CDC, in normal Apex Trigger for Sobject, after insert,update and delete, undelete trigger fire an EVENT with JSON serialized data of field data that has changed with a Platform event with type field as INSERT,UPDATE, DELETE, UNDELETE.

Also as its apex code, it gives you flexibility to change and partially disable in case you doing data load/cleanup activity and you dont care about those irrelevant fields.

Source : Link , Question Author : Raman , Answer Author : Pranay Jaiswal

Leave a Comment