Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 21:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×I am writing my own plugin.
I have 2 listeners. The first one runs when an issue is transitioned and then based on a bunch of conditions may fire a custom event.
The second listener should only run when the custom event is fired but for some reason isn't running when the first event fires the event.( I have a few log statements before doing the check on which event type is being handled so I know it is in fact listening for events)
I have temporarily installed script runner and created a listener that runs on the custom event to check if the event is being fired and it is.
Listener that should run when issues are transitioned: (I know is working)
@EventListener
public void onIssueEvent(IssueEvent event) {
LOG.debug("Trigger Listener");
if (!needsToHandle(event)) {
LOG.debug("Dont need to handle event {}", event.getEventTypeId());
return;
}
triggerLocator.getActiveAndValid().stream()
.filter(trigger -> triggerMatchesIssue(trigger, event.getIssue()))
.forEach(trigger ->
actionLocator.getActionsForTrigger(trigger).forEach(action -> fireAction(action, event)));
}
private void fireAction(Action action, IssueEvent event) {
getProvider(action.getGroup().getFunction()).ifPresent(provider -> {
provider.setComponentLocator(this);
List<Contact> contacts = provider.getContacts(event.getIssue(), action.getGroup());
Map<String, Object> params = new HashMap<>();
params.put("action", action);
params.put("contactsMap", asListOfMaps(contacts));
IssueEvent toDispatch = new IssueEvent(event.getIssue(), params, event.getUser(), eventType.getId(), false);
issueEventManager.dispatchEvent(issueEventFactory.wrapInBundle(toDispatch));
LOG.debug("Dispatched {} event for action : {}", eventType.getName(), action.getName());
});
}
Listener that should only run on custom event: (Not running on events fired by previous)
@EventListener
public void onIssueEvent(IssueEvent event) {
LOG.debug("Notification Listener");
if(event.getEventTypeId() != eventType.getId()){
LOG.debug("event eventTypeId {}",event.getEventTypeId());
LOG.debug("event type id {}",eventType.getId());
eventTypeManager.getEventTypes().stream()
.filter(type -> Objects.equals(event.getEventTypeId(), type.getId()))
.findFirst().ifPresent(eventType1 -> {
LOG.debug(eventType1.getName());
});
return;
}
LOG.debug("Running Notification LIstener");
}
Any help would be appreciated because I dont want to have to call the 2nd listeners method directly
Use :
eventPublisher.publish(toDispatch);
inplace of :
issueEventManager.dispatchEvent(issueEventFactory.wrapInBundle(toDispatch));
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.