I've created a listener and throw an event. The listener displays a notification. This works fine until I dispatch the event from within the new thread.
Listener:
def flag = [
type: "info", //Other possible options are "info", "success", "error"
body: "${event["params"]["issue"]}",
close: "manual",
title: "Epic Cloning in progress"
]
com.onresolve.scriptrunner.runner.util.UserMessageUtil.flag(flag)
UserMessageUtil is a wrapper for Atlassian UI (AUI) - Flag
Script to throw event:
This works:
IssueEventManager issueEventM = ComponentAccessor.getIssueEventManager()
IssueEventBundleFactory issueEventFactory = (IssueEventBundleFactory) ComponentAccessor.getComponent(IssueEventBundleFactory.class)
IssueEventBundle eventBundle = issueEventFactory.wrapInBundle(new IssueEvent(epic, ["issue": epic], user, 10001, false))
issueEventM.dispatchEvent(eventBundle)
This doesn't:
Thread.start {
JiraThreadLocalUtils.preCall();
IssueEventManager issueEventM = ComponentAccessor.getIssueEventManager()
IssueEventBundleFactory issueEventFactory = (IssueEventBundleFactory) ComponentAccessor.getComponent(IssueEventBundleFactory.class)
IssueEventBundle eventBundle = issueEventFactory.wrapInBundle(new IssueEvent(epic, ["issue": epic], user, 10001, false))
issueEventM.dispatchEvent(eventBundle)
JiraThreadLocalUtils.postCall()
}
How can I raise the event from within the thread?