Override Jira core service

Bartłomiej Bartłomiej October 23, 2017

Hi,

Is there any way to override jira service (eg. using AOP)?

I'd like to filter MailQueueItems inside MailQueue before MailQueueService starts to process it. It would be ideally to override MailQueueService.run() method - but probably it is not possible.

I've spent lots of time without any success. Please let me know how can I do it.

I can prepare scheduled job and check queue, but this solution is not good, because internal jira jobs runs as default once a minute, and there is a risk, that new elements appear on queue after my job finishes.

How it coul'd be done in jira plugin development?

Bart

1 answer

0 votes
Gregor Kasmann_Actonic
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.
October 24, 2017

You cannot override logic of MailQueueService.

What is your task? What exactly you would like to change in MailQueueService.run() method?

Bartłomiej Bartłomiej October 24, 2017

Hi,

my task is the following:

  1. user can configure additional email address in profile [done, using AO]
  2. each notification should be send to this additional email [done, using eventlistener]
  3. - if user has additional email, i can't send email to standard email - here I don't have idea how to do it. I've tried to remove unnecessary email from the queue before MailQueueService starts to process it - but it seems to be impossible)

Could You help me in point 3?

Bart

Gregor Kasmann_Actonic
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.
October 24, 2017

No, it is not possible at the moment

Bartłomiej Bartłomiej October 24, 2017

Isn't it possible to add some listener and check what is added to mail queue and modify it before email sending starts?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 24, 2017

No, it's too late in the process.

Events are fired when something happens.  There's a built-in listener that picks them up and sends out notifications.

You have no way of knowing if your listener will react to an event before, during, or after another listener, and even if you could be sure it runs before the notification listener, events are not modifiable, so you wouldn't be able to do anything with it.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 24, 2017

You will need to remove the notifications completely, so that Jira does not do anything with the events, and write your own notification listener.

Bartłomiej Bartłomiej October 24, 2017

ok, I'll talk with PM about this requirement :)

Bartłomiej Bartłomiej October 24, 2017

I assume that there is no way to override build-in listener?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 24, 2017

Not without hacking the core of Jira apart.

Bartłomiej Bartłomiej October 24, 2017

ok, thank You!

Suggest an answer

Log in or Sign up to answer