ARC-101 practice question 8 of 25

An Integration Architect has built a Salesforce application that integrates multiple systems and keeps them synchronized via Platform Events. What is taking place if events are only being published?

Full set: 106 questions
Answer options
A: The platform events are published immediately before the Apex transaction completes.
B: The platform events are published after the Apex transaction completes. Correct answer
C: The platform events has a trigger in Apex.
D: The platform events are being published from Apex.
Correct Answer:
B. The platform events are published after the Apex transaction completes.
Explanation

In Salesforce, when Platform Events are published from within an Apex transaction using the EventBus.publish() method, the events are not sent immediately. Instead, they are queued. The actual publication to the event bus occurs only after the entire Apex transaction has been successfully committed to the database. This transactional behavior is a critical feature that ensures data consistency, as it prevents events from being published if the originating transaction fails and is rolled back. The events are discarded along with the other rolled-back changes.

References

1. Salesforce Platform Events Developer Guide, "Publish Events with Apex": "To publish an event message, you call the EventBus.publish() method... The event is published after the transaction is committed. If the transaction fails, the event isn't published."

2. Salesforce Apex Developer Guide, "EventBus Class": The documentation for the publish method states: "The publishing of events is transactional. The events are published only after the transaction completes successfully. If the transaction is rolled back, the events aren't published."

3. Salesforce Platform Events Basics Trailhead Module, "Publish and Subscribe to Platform Events": "When you publish a platform event with Apex, the EventBus.publish() method call is queued. The event is actually published when the transaction is successfully committed."

Scroll to Top