function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bhagyashree JogBhagyashree Jog 

Salesforce platform event EMP Connector replay lost message

We are subscribing to Push Topics and Platform Events using CometD Subscriber using the code in the EMP Connector provided on GitHub.

Scenario:
Take the case of a subscriber listening on channel /topic/channel. The replayId is -1
Lets say the subscriber received messages upto replayId 20 and then due to some reason the subscriber went down and then came up and started listening on the channel again
In the time the subscriber was down four new events were published. But when the subscriber comes up it will start receiving messages from 25 since the replay id is -1

Question : Is there any way to ensure that the subscriber starts listening from id 21 when it comes up. 
I know that one way is to give the replay id as 21. But that is not suitable for our application
Is there a way to query salesforce through cometD or any SOAP/REST API to check the last received event's replayID and then start the subscriber from that. 
Can we use EventBusSubcriber for this? I started our application and subscribed to a platform event through cometd and tried querying the entries in EventBusSubcriber. But it did not have any entries
Raghuveer Mukkamalla 14Raghuveer Mukkamalla 14
May not help you with what you are asking but do note that this is a client capability (for example, MuleSoft's Salesforce connector gives you the option to retrieve from the last ReplayID).

There is not a way to query for platform events but even if you can, how can Salesforce know that your application/ a particular subscriber went down after ReplayID 20?