What is the difference between asynchronous and synchronous execution of Object Event Handlers in the custom process?
Environment:
Process Designer, Custom Process Model (CPM) / Service Process Model (SPM)
All product versions
Resolution:
Synchronous execution of an Object Event Handler has a strict time limit of 5 seconds. It is intended for processes that are executed without interruption from start to finish. Synchronous execution of an Object Event handler requires the code executing it to wait until the handler is completed to continue execution. This applies to those triggered using Surveys and Campaigns, as only synchronous CPMs can be used in those cases.
Asynchronous execution of an Object Event Handler has a time limit of 157 seconds of processing time, execution is controlled by a queuing system. When asynchronous CPMs are triggered through a mapping in the Process Designer (only, as this does not occur for those triggered from business rules, surveys or campaigns), and if there is a failure to execute the first time (due to an uncaught or thrown exception or other error), the process can be repeated up to nine times. For further details on this see
Also, asynchronous execution is intended for event handlers that do not need to execute immediately. An example that may use asynchronous execution could be an integration that updates contact information in an external database when a contact is created in Oracle B2C Service. The site utility for the queue that processes asynchronous CPMs will only hold a maximum of three database connections at a time. While the use of this product feature allows for a high volume of functionality to process without overloading the site database, this is part of the design of this product feature that results in no guarantee that the queue will always be current (and not have a backlog).
For further details on this see
Answer ID 12316: Managing Asynchronous CPMs
To set the event handler to execute asynchronously, select the Execute Asynchronously check box and/or name the handler with the async keyword. This needs to be done before a CPM customization is first saved, since this aspect of the configuration is non-editable for existing CPM customizations. For details on how to delete a CPM customization see
Answer ID 7883: Delete Custom Process Model Script (CPM)
For more information, refer to the following:
Answer ID 9453: Two second guideline for synchronous CPMs
Answer ID 6907: Limitations of synchronous object event handlers when attached to the answer object.