Hello all,
I have a send custom email on post function transition.
I would like to check the error queue after the email is sent either by the same post function or script listener to see if the email has been sent with no errors.
It takes approx. 12 mins after for the email to go to the error queue if the email is unsuccessful, so i need to post-pone my script to check the email queue 12 mins after post function.
I've managed to compile the below Code to run in fast track transition so if the condition is true then it transitions its status:
import java.util.concurrent.TimeUnit TimeUnit.MINUTES.sleep(13) // Takes 13 mins after retry to go into error queue when unsuccessful import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.event.type.EventDispatchOption import com.atlassian.jira.issue.UpdateIssueRequest import com.atlassian.mail.queue.MailQueue import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.MutableIssue Issue issue = issue CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager() def mailQueue = ComponentAccessor.getComponent(MailQueue) String key = issue.getKey() String errorQueue = mailQueue.getErrorQueue() if (errorQueue.contains(key)) return true else false
But if i do this, the transition screen wont proceed and will be stuck in loading for 13 mins.
What its suppose to do is, basically checks the error email queue when the email is sent 13 mins after and then identify if the issue key is in the error queue then it should transition to a "failed reply" status.
Is there any way around this or can anyone offer a better solution to check for the error queue after the email has been sent.
Many thanks,
Pon
You'd have to start a new thread... but it seems like a bad solution.
new Thread({ // do stuff }).run()
Why might the email fail to be sent? Why does it take 12 minutes to get there?
If you must do this maybe consider using a service: to run every 10 mins and check the error queue, making sure to remove it from the queue once processed.
The email keeps on retrying to send for around 12 minutes, i think its a configuration on the server side.
Thank you for recommending me service.
What i was trying to do is if there is a mail in the errorQueue, then it would transition that issue to a failed delivery status extracting the issue key from the subject.
And service does exactly this. I've placed the above code to Escalation service and works like a charm.
Cheers,
Pon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.