Hello,
I'd like to set up a Scriptrunner Custom Scheduled Job to send a Custom Event once per day. This custom event would then be picked up by a Listener (for issue events) and fire off a custom email rounding up some key information.
I realize that I can also generate emails directly from a Custom Job, but the Listener interface is much easier for generating a complex HTML template with in-line database queries.
I have the following code, which seems to fire the event off just fine:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEventManager
import com.atlassian.jira.event.issue.IssueEventBundleFactory
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.issue.IssueEventBundle
import com.atlassian.jira.issue.Issue
IssueEventManager issueEventM = ComponentAccessor.getIssueEventManager()
IssueEventBundleFactory issueEventFactory = (IssueEventBundleFactory) ComponentAccessor.getComponent(IssueEventBundleFactory.class)
def userManager = ComponentAccessor.getUserManager();
def automationUser = userManager.getUserByName("user_name");
Issue issue
int EVENT_ID = 10100
IssueEventBundle eventBundle = issueEventFactory.wrapInBundle(new IssueEvent (issue, null, automationUser, (Long)EVENT_ID, true))
issueEventM.dispatchEvent(eventBundle)
However the Listener errors out and I am not sure why. Possibly the dummy issue and dummy user used to dispatch the event? The listener currently has no code in it, just an HTML template that triggers on Event 10100.
Here is part of the Listener log:
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy7043.execute(Unknown Source)