Hi,
I created a custom IncidentHandler
which extends DefaultIncidentHandler
and registered it into my process engine.
When an exception is occured anywhere within my JavaDelegates, my IncidentHandler#handleIncident
method is working successfully but the issue is the incident is not inserted to DB. When I check act_hi_incident and act_ru_incident I can’t see any record created.
Additionally, after a while, the IncidentHandler#handleIncident
method works again for same error. I think somehow the engine tries to retry
that incident
This is my incident handler:
@Component
@Slf4j
public class IncidentHandler extends DefaultIncidentHandler {
private final BpmStateMessageSender messageSender;
private final ApplicationContext applicationContext;
public IncidentHandler(BpmStateMessageSender messageSender, ApplicationContext applicationContext) {
super(Incident.FAILED_JOB_HANDLER_TYPE);
this.messageSender = messageSender;
this.applicationContext = applicationContext;
}
@Override
public Incident handleIncident(IncidentContext context, String message) {
ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class);
log.debug("INCIDENT HAPPENED : {}", message);
try {
log.debug("Fetching active execution");
ProcessInstance processInstance = (ProcessInstance) processEngine
.getRuntimeService()
.createExecutionQuery()
.active()
.executionId(context.getExecutionId())
.singleResult();
log.debug("Found execution: {}", processInstance);
log.debug("Building websocket message..");
WebSocketMessage streamMessage = WebSocketMessage.builder()
.status(ProcessStatus.INCIDENT_HAPPENED)
.user(ProcessUtil.getUserAssigneeId())
.businessKey(processInstance.getBusinessKey())
.build();
log.debug("Sending websocket message..");
messageSender.send(streamMessage);
} catch (Exception e) {
log.error("Failed on sending incident message through websocket");
log.error(e.getMessage(), e);
}
return super.handleIncident(context, message);
}
}