0

We are using a custom Email To Case Handler apex class. So that we can keep track of incoming emails if the custom handler crashes for any reason, we have just implemented code at the start of the handler to call a Queueable Apex class, and pass it the incoming email and envelope. What we are finding is that if the custom email handler crashes, then Queueable job does not seem to run. If the custom email handler finishes without crashing, then and only then does the Queuable job run. Is this expected behavior?

1

Yes, this is the expected behavior. A transaction must run to completion (complete without hitting a governor limit, failed assertion, or uncaught exception), or the entire transaction will be rolled back, including any emails sent with Messaging.sendEmail, jobs queued with System.enqueueJob, System.schedule, or Database.executeBatch, and so on. While you're here reading this answer, be sure to vote on this idea.

4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.