Make Apex Callouts After Publishing Platform Event Messages

You can now make Apex callouts after publishing event messages for events configured with the Publish Immediately behavior. Previously, after publishing such events, you couldn't make callouts from any Apex code. Events published immediately have a new limit, which is separate from the Apex DML statement limit.

Where: This change applies to Enterprise, Performance, Unlimited, and Developer editions.

Why: Events configured with the Publish Immediately behavior are published when the call executes and they don't depend on the successful completion of the transaction. These events are used for tracking and logging purposes. With this change, they aren't considered part of the transaction's DML operations, and therefore no longer prevent Apex callouts from being performed after publishing. They count against a new, separate publishing limit of 150 EventBus.publish() calls. This change doesn't apply to events configured with the Publish After Commit behavior, whose publishing is considered part of the transaction's DML operations. The publishing of these events still counts against the Apex DML statement limit. And you can still make Apex callouts after publishing.

To track the limit usage of EventBus.publish() calls for immediate publishing, use the Limits.getPublishImmediateDML() and Limits.getLimitPublishImmediateDML() Apex methods.

Note

Note

This feature doesn't change the way you make Apex callouts from Apex triggers, which require the @future(callout=true) annotation.