INTEGRATION-ARCHITECTURE-DESIGNER practice question 21 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

Domain Design an Integration Solution

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

When a platform event is published within a Salesforce transaction (e.g., from an Apex trigger or a Flow), the event message is not sent to the event bus immediately. Instead, it is queued. The actual publication occurs only after the associated database transaction has been successfully committed. This transactional behavior is a critical design feature that ensures data consistency. If the transaction were to fail and roll back for any reason, the queued event message would be discarded and never published, preventing external systems from acting on data that was never permanently saved in Salesforce.

Why Incorrect

A. The platform events are published immediately before the Apex transaction completes. This is incorrect. Publishing before a commit could lead to external systems receiving notifications about data changes that are ultimately rolled back, causing data inconsistency.
C. The platform events has a trigger in Apex. An Apex trigger on a platform event is for subscribing to (consuming) events, not publishing them. The question is about the act of publishing.
D. The platform events are being published from Apex. While publishing from Apex is a common method, it is not the only one (e.g., Flows, APIs). This option describes a potential implementation method, not the fundamental transactional process that occurs during publication.

References

1. Salesforce Platform Events Developer Guide, "Publish Platform Events" section: "To publish event messages, you call the EventBus.publish() method... The publishing of the event message happens after the transaction is successfully committed. If the transaction fails, the event message isn't published."

2. Apex Developer Guide, "EventBus Class" section: Under the publish method description, it states: "The publish method queues the event for publishing. The event is published asynchronously after the transaction is committed."

3. Salesforce Architects, "Architect's Guide to Event-Driven Architecture with Salesforce" Whitepaper, Page 10: "When publishing platform events from Apex, the publish operation is transactional with the Salesforce transaction. That is, the event is only published if the transaction completes successfully."

Scroll to Top