I'm publishing Platform Events using APEX Code EventBus.publish method and consuming the events in backend Java app using EventListener.

Problem

All the published events remains in EventBus and whenever my consumer Java app restarts, listener is receiving all the previously published events (in the past 24 hrs?, not sure about the timing though).

Is there any way to clear the events published to EventBus after some set interval? I've gone through the Platform Events documentation and couldn't find any help to tackle this problem.

Any pointer would be helpful

up vote 4 down vote accepted

This is a feature called Event Durability. It is expected that the client retains the last replayId it has seen, and pass this in to the streaming handshake to resume where they left off. There's no way to clear this early and yet provide durability. The events do drop off after 24 hours. You will need to modify your code to remember the last replayId.

  • Got it! Thanks for pointing me in the right direction to track replayId. Will play around. – jusermar10 Nov 16 at 16:26

You cannot delete Platform Event records. This is mentioned in the documentation:

Unlike custom objects, you can’t update or delete event records.

The only way you can delete event records is by deleting its definition altogether:

When you delete a platform event definition, it’s permanently deleted.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.