Synchronous vs Asynchronous
Most of the listeners you encounter in Jira and see provided by the most of the apps are synchronous. This means that the code runs on the same thread where the event was created. Updating an issue and listening for those changes will trigger the listener(s) which will be executed, and the control is not given back to the user until it is done. This might seem simple, but is not always the best approach.
Suppose you need to keep statistics about users and their engagement with various products. When a user changes an issue on some project, you would like to increment a counter in some external database. Makes no sense to wait for this operation to complete. This is why Power Scripts offers asynchronous listeners, opening the path for better performance and better response time for our users.
However, keep in mind that with asynchronous operations, you are not allowed to modify the issue because modifications will be discarded upon exit. With synchronous operations, you are allowed to modify that issue.
So, we recommend that you use synchronous listeners for the following cases:
You want to modify the issue(s), or
There's a sequence of operations that need to be respected and those cannot be packed in a single script, or
Listener execution is short
Use asynchronous listeners when:
You do not want to modify the issue(s), and
Performance matters and there is a listener that performs lengthy operations
Mixing asynchronous with synchronous listeners
You can mix asynchronous with synchronous listeners. However, the execution order makes no sense when we talk about asynchronous listeners. The order you establish on the management page is not the order of execution, but the order of launch.
See More