I’m unable to run the sample with the current version.
It’s forcing me to override newConfiguration method and it crashes on test.
Is there another class I should extend now instead of implementing JobHandler?
public class EscalationJobHandler implements JobHandler {
private static final Logger log = Logger.getLogger(EscalationJobHandler.class.getName());
public static final String ESCALATION_JOB_HANDLER_TYPE = "escalationJob";
@Override
public String getType() {
return ESCALATION_JOB_HANDLER_TYPE;
}
@Override
public void execute(JobHandlerConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String arg3) {
log.info("\n\nEscalation received! " + execution.getId() + "\n\n");
log.info(execution.getActivity().getName());
}
@Override
public JobHandlerConfiguration newConfiguration(String canonicalString) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onDelete(JobHandlerConfiguration configuration, JobEntity jobEntity) {
// TODO Auto-generated method stub
}
}
log.info("create job for escalation for task " + delegateTask.getId());
ExecutionEntity execution = (ExecutionEntity) delegateTask.getExecution();
ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) execution.getProcessDefinition();
TimerEntity timer = new TimerEntity();
timer.setExecution(execution);
timer.setDuedate(delegateTask.getDueDate());
timer.setJobHandlerType(EscalationJobHandler.ESCALATION_JOB_HANDLER_TYPE);
timer.setProcessDefinitionKey(processDefinition.getKey());
timer.setDeploymentId(processDefinition.getDeploymentId());
Context.getCommandContext().getJobManager().schedule(timer);
Ont this is the error I got:
10:09:36.198 [main] ERROR org.camunda.bpm.engine.context - ENGINE-16004 Exception while closing command context: null
java.lang.NullPointerException: null
at org.camunda.bpm.engine.impl.persistence.entity.JobEntity.getJobHandlerConfiguration(JobEntity.java:465) ~[camunda-engine-7.6.0.jar:7.6.0]
at org.camunda.bpm.engine.impl.persistence.entity.JobEntity.execute(JobEntity.java:127) ~[camunda-engine-7.6.0.jar:7.6.0]
at org.camunda.bpm.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:99) ~[camunda-engine-7.6.0.jar:7.6.0]
at org.camunda.bpm.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:36) ~[camunda-engine-7.6.0.jar:7.6.0]
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24) ~[camunda-engine-7.6.0.jar:7.6.0]
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104) ~[camunda-engine-7.6.0.jar:7.6.0]
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66) [camunda-engine-7.6.0.jar:7.6.0]
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30) [camunda-engine-7.6.0.jar:7.6.0]
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:35) [camunda-engine-7.6.0.jar:7.6.0]
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:28) [camunda-engine-7.6.0.jar:7.6.0]
at org.camunda.bpm.engine.impl.ManagementServiceImpl.executeJob(ManagementServiceImpl.java:115) [camunda-engine-7.6.0.jar:7.6.0]
As I said, you have to register your EscalationJobHandler on the process engine configuration. You can do this for example in your CommunicationProcessEnginePlugin like this:
public class CommunicationProcessEnginePlugin implements ProcessEnginePlugin {
@Override
public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
processEngineConfiguration.getJobHandlers().put(EscalationJobHandler.ESCALATION_JOB_HANDLER_TYPE, new EscalationJobHandler());
}
}