Salesforce Change Data Capture reconnection and replayId

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Salesforce Change Data Capture reconnection and replayId


I'm subscribing to Salesforce Change Data Capture events. I had the
problem that after 24 hours the replayId is stale and if Camel tries
to reconnect to it it throws an error (I asked about this here:

As suggested by Zoran Regvart I'm storing the replayId and the
timestamp, so on app startup if I know the replayId is old enough, I
pass ?replayId=-2 to replay all events.

This works fine, but the problem I'm facing now is that if the app
reconnects after some time I get this event:

Connect failure: {advice={reconnect=handshake, interval=0},
channel=/meta/connect, id=3320, error=403::Unknown client,

And then the client will try to reconnect automatically using the
latest replayId. Since this logic is handled by SubscriptionHelper, if
the replayId is old enough it will fail on reconnect and then the app
will stop receiving events forever.

The only thing I can think of is to always use replayId=-2 to fetch
all events and ignore the ones I already processed, but it seems
suboptimal to say the least.

How should I handle this scenario so that the implementation is robust?