Salesforce Certified Platform Developer II Practice Questions

Salesforce Certified Platform Developer II exam preparation

Salesforce Certified Platform Developer II practice questions in English: 180 questions with explanations. The mock exam has 60 questions and 120 minutes.

Salesforce Certified Platform Developer II free question 3 / 10 · Domain 2: Process Automation, Logic, and Integration

Three platform event messages are published together with one call to EventBus.publish(). One of them can't be published because a required field is empty. Which statement matches the documentation?

  1. isSuccess() is true in the SaveResult of all three events, and the failure is reported later by email
  2. An exception is thrown when an event fails, and the publishing of the three is cancelled
  3. The other two events can be published, and the failure shows up as an error in the returned SaveResult
  4. The failed event enters a retry queue and is published again until it succeeds
Show the answer and explanation

Answer: C

Why this is correct
The "Immediate Publish Result in Database.SaveResult" section says that for each event, Database.SaveResult contains information about whether the operation was successful and the errors encountered. If isSuccess() returns false, the publish operation resulted in errors, which are returned in the Database.Error object. EventBus.publish() can publish some passed-in events even when other events can't be published due to errors, and it doesn't throw exceptions caused by an unsuccessful publish operation. It is similar in behavior to the Apex Database.insert method when called with the partial success option.

Why the other options are wrong
"An exception is thrown when an event fails, and the publishing of the three is cancelled" … The page says EventBus.publish() can publish some of the events even when others fail, and that it doesn't throw exceptions caused by an unsuccessful publish operation.
"The failed event enters a retry queue and is published again until it succeeds" … The page reports the failure in the Database.Error of the SaveResult. It describes no retry queue that publishes the event again automatically.
"isSuccess() is true in the SaveResult of all three events, and the failure is reported later by email" … For an event that could not be published, isSuccess() returns false and the errors are returned in the Database.Error object. The failure is not reported later by email.

What a successful result means
If isSuccess() returns true, the publish request is queued in Salesforce and the event message is published asynchronously; the status code OPERATION_ENQUEUED is returned for a successful call. Without an Apex publish callback, you can get only the intermediate queueing result in the SaveResult, not the final result.

Go to the Salesforce Certified Platform Developer II practice app (10 free questions; purchase unlocks all questions)

See the full practice set