How to use AsynchronousPreferred

Hello

After issue update I want to do stuff (jql, another issue update) asynchronously in the listener
I saw AsynchronousPreferred docs
in Jira but there isn’t any example how to use it.
Can someone assist

Thanks,
Ibrahim

1 Like

I saw AsynchronousPreferred docs
in Jira but there isn’t any example how to use it.
Can you assist

You must create Event class with this annotation, for example:

@AsynchronousPreferred
public class AsyncIssueEvent {
    ...
    public AsyncIssueEvent(IssueEvent issueEvent)
}

When you listen generic IssueEvent (that in fact don’t async), you create common listener:

public class CommonIssueListener {
    private final EventPublisher eventPublisher;
    ....
    @EventListener
    public void onEvent(IssueEvent event) {
        ...
        this.eventPublisher.publish(new AsyncIssueEvent(event));
    }  
}

and after this create class for async listener:

public class AsyncIssueEventListener {
     ...
     @EventListener
     public void onAsyncIssueEvent(AsyncIssueEvent event)
}