8

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

2 Answers 2

11

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.

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

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.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .