Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Listener and Performance

Dang Thi Thuy Tien
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 2019

Hi,

I have a question about the listener and performance.

For example:

I have 5 class:

 + Add Attachment Listener

 + Priority Field Change Listener

 + Add Comment Listener

 + Change Status of Issue Listener

 + Change Assignee Listener

All of the classes will listen on

 @EventListener public void onIssueEvent(IssueEvent issueEvent) { 
// Do some thing
}

I have 2 way implemented for this problem

Option 1: I register 5 class like this:

eventPublisher.register(AddAttachmentListener.class); 
eventPublisher.register(PriorityFieldChangeListener.class);
eventPublisher.register(AddCommentListener.class);
eventPublisher.register(ChangeStatusOfIssueListener.class);
eventPublisher.register(ChangeAssigneeListener.class);

And use inside each class function onIssueEvent()

Option 2:

I just register only one class:

eventPublisher.register(IssueEventListener.class);

And in the function onIssueEvent() I will switch to each event.

But, If I register 5 class it will make the code cleaner and easy for reading.

So, which option could I follow?

If I use option 1, will I affect the performance?

 

Thank you

1 answer

0 votes
Gonchik Tsymzhitov
Community Champion
February 18, 2021

Hi! 

you followed 1 option, as 5 listener is too low

Suggest an answer

Log in or Sign up to answer