2

Based on Triggers and Order of Execution document, it is unclear at which point outbound messages are executed:

10. Executes workflow rules.
<..>
19. Commits all DML operations to the database.
20. Executes post-commit logic, such as sending email.

Will long running OBM would lock the record until it is complete?

If I have future method that may update self, would that cause a deadlock?

1 Answer 1

8

Outbound messages are executed asynchronously. When a workflow rule causes an outbound message to fire, it's simply placed into a queue for later execution. A future method would fire before an outbound message would most likely fire off before an outbound message would have a chance to go, and the row-locking algorithm would make sure that the two play nice with each other, although there could be a distinct possibility that one could overwrite changes from the other, but only for fields they directly touch.

Salesforce's general policy is "don't allow external systems to be corrupted from failed transactions." This policy is why you can't make a callout after a DML operation, for example, because the transaction could later be rolled back after the callout, thus causing the external system to be out of sync. Similarly, outbound messages can be rolled back before they're finally sent, so you can guarantee that the outbound message can't fire before step 20.

2
  • So they are queued at step 10 and if nothing failed, executed (or scheduled for execution) at step 20?
    – dzh
    Jun 13, 2016 at 23:12
  • @dzh That's the best way to visualize it. They have to survive until the final database commit before they'll be sent off.
    – sfdcfox
    Jun 13, 2016 at 23:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .