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 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