I have an apex trigger that posts platform events, there is another apex trigger which is a subscriber to the platform events. In production, if I encounter any bug in the logic in my subscriber apex trigger, I would like to know how to bring the subscriber down? And if there are any events that are published but not yet consumed, will they still be stored queued in flight so that once my subscriber is back up again it can consume and process the other events?


You can disable your subscriber Trigger in APEX via Hierarchical custom settings like you do for normal Apex trigger:

trigger MyEventTrigger on CustomEvent__e (after insert) {

 if(!SomeCustomSetting__c.getInstance().ActivateTheTrigger__c) {
     System.debug('Bypassing trigger due to custom setting');

 // Rest of the trigger body ...


SRC: https://salesforce.stackexchange.com/a/166254/19118

Regarding your second question: Yes platfom events published will be available for you to replay upto 24 hours. Only limitation is replaying feature is only supported bu API.

According to docs:

You can replay platform events that were sent in the past 24 hours. You can replay platform events through the API (CometD) but not Apex. The process of replaying platform events is the same as for other Streaming API events.

Source: https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_api_considerations.htm

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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