Forums

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

What is the order for listeners versus notification events?

Rob Baily February 1, 2012

My question has multiple parts:

  • Is it guaranteed that custom listeners would fire before notification events? I am asking because we have a listener that looks for created events and sets some user values. For the Event Created notification we have messages going to the values that were just set. Normally this works fine but in some instances it stops working and the notifications go to the users who are not ones just added by the custom listener. My only guess is that our listener is firing after the notification event. We are currently version 4.1.2 and upgrading to 4.4 soon if that matters. If my guess is correct is there any way to verify this? I can't tell how to get a log message to see when the notifications occur.
  • Is there any way to guarantee the order of custom listeners to ensure one fires after a dependent one?

Thanks in advance for any help or guidance!

1 answer

1 accepted

0 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
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.
February 1, 2012

As per my understanding, both listeners and notifications are based on events but you cannot guarantee which one happens first because both are different threads.

If you set something in the listener, notifications might miss it. You should try setting the values in Create Post function and make sure the post function is executed before the event is thrown.

Nic Brough -Adaptavist-
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.
February 1, 2012

In my experience (and having had colleagues dig through the code), Jobin is exactly right - there is no "order" to listeners and events. Listeners listen, events get fired, and whichever listener happens to pick it up first runs first. I've boiled this down to the assumptions that

  1. Never try to amend an issue with more than one listener, because you can't know which edit will happen first
  2. Never assume any order to reactions to your events, because you can't know what's listening.
  3. Data required in emails or listeners must be set in post-functions, before the event is fired, because the event contains a copy of the change.

It's a bit like reading a newspaper - it might be printed in a specific order, but the printer has no way of forcing me to read it in that order.

Rob Baily February 1, 2012

I don't see how to add a Post Function for Create in JIRA 4.1. It looks maybe this is available in the Design mode in JIRA 4.4. Does that sound right?

It sounds like what I would really need to guarantee order is to create a new custom event, include that in the post functions before the generic Issue Created event and then have our plugin fire on that custom event. Does that sound correct?

Jobin Kuruvilla [Adaptavist]
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.
February 1, 2012

Checkout http://confluence.atlassian.com/display/JIRA041/Configuring+Workflow#ConfiguringWorkflow-Addingapostfunction to find out how to add post function under Create. See the Note.

Rob Baily February 2, 2012

I looked at this a little more and it turns out that I cannot add another event as a post function so I cannot fire something different before the Issue Created event. Given that I want to read another database I guess the approach would be that I need to create a custom post function and use it.

Jobin Kuruvilla [Adaptavist]
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.
February 3, 2012

yup, you can't throw multiple events. You need a post function.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events