We have a platform event, let's call it Event__e, with one field called Identity__c.

We provide a global apex class with an invocable method on it, let's call it EventPublisher.publish that accepts a list of "names" (strings) and creates an Event__e instance per "name", storing the supplied "name" in the Identity__c field and then publishes the events on the event bus using:


We then have a trigger subscribed to this event that takes the platform events and processes them.

This invocable method is itself called from a Process Builder, passing in just a single name.

Our event used to have the publish behaviour of "Publish Immediately" and this worked (the events were received by the trigger-based subscriber), but we were not getting quite the behaviour we wanted - the data the process builder was manipulating was not available in the database when the trigger-based subscriber was processing the events.

We thus changed the Event__e publish behaviour to "Publish After Commit".

Now the process builder never causes the trigger-based subscriber to be called. Any idea what's going wrong?

1 Answer 1


If you read the documentation for platform events, you can see that the Publish Behaviour is described:

Publish After Commit to have the event message published only after a transaction commits successfully. Select this option if subscribers rely on data that the publishing transaction commits

If you then consider the documentation for Invocable Methods:

Invocable methods are called with REST API and used to invoke a single Apex method. Invocable methods have dynamic input and output values and support describe calls

(My emphasis)

Combining these two points together, it becomes clear that the invocable method actually has a completely separate transaction. Given that the invocable method itself performs no DML operations, selecting Publish After Commit for the publish behaviour actually means that the events published to the event bus simply disappear at the end of the transaction (when the invocable method terminates) - essentially, there is no "commit" in this invocable method's transaction.

The solution here is to replace the use of the invocable method in the Process Builder, changing the original "Immediate Action" from "Call Apex" to "Create a Record", where the record type to create is set to Event__e and the required "name" is simply set in the Identity__c field. This event record is then itself committed as part of the contextual transaction and will be sent to and processed by the trigger-based subscriber.

You must log in to answer this question.

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