+ Start a Discussion
Georges Auberger 7Georges Auberger 7 

PushTopic replayId outside of retention window

It looks like if you pass a replayId for an event that is outside of the retention window, you don't get anyhting replayed, nor do you get any event for newly created events. Is that expected behavior?
Roshni RahulRoshni Rahul
Hi Geoges,

We cant get replay for events that happens outside the retention window. 

A subscriber can choose which events to receive, such as all events within the retention window or starting after a particular event. The default is to receive only the new events sent after subscribing. Events outside the 24-hour retention period are discarded.
Hope its helpful to you

Georges Auberger 7Georges Auberger 7
I did not expect those events to be replayed. What I would expect is for all events in the retention window, plus new event to be replayed. Essentially the same behavior as when replayID = -2. The problem I have is that a subscriber does not know if the last good known replayId it has is in or out of the retention window. If it is out of the retention window, how does the subscriber know that it won't get anything, including new events?
Roshni RahulRoshni Rahul
Hi George,

Best way to get Reply for all the topic a subscriber has, is to subcribe to all the pushtopics that you created before without recreating them, together with the subscription of your new pushtopics.
Since your subscriber does not know the last good known ReplayID is in or out of the retention window, you have to store all the created Pushtopic data so that you can subscribe to them in for all the active retention windows.
If you have any further queries, feel free to ask.

Mark ShapiroMark Shapiro
This really doesn't solve the problem at all.  When I receive a message on a pushtopic, I store the latest ReplayID so that if my client application disconnects and later reconnects, it can get all available messages from where it left off.  If it reconnects within 24 hours and sends its latest ReplayID, it won't miss anything - all the messages will be in the replay window and will be sent.  If it reconnects after 24 hours, and sends its latest ReplayID, it won't get ANYTHING, not even new messages.  This is broken.  If the ReplayID is outside the available window, the SalesForce server should treat it as -2 (replay all), or WORST CASE, -1 (replay none), it shouldn't "not send anything, even new messages", which is the current broken behavior.

As is, ReplayID is effectively useless.
Mit SutharMit Suthar
Hi Mark,
Ideally, if the replay id falls outside of retention window, it shold be treated as -2 or -1.
I would say this is a borken behaviour at best but there is workaround you can apply.
Your application can handle this.
On recovering a crash subscribe via a -2 first. Look at all the messages and see if your last known replay id is there.
If yes, unsubscribe, set replay id and subscribe again.
If no, means your application took more than 24 hours to recover. start processing the queue you got from -2.