Add custom work to jobexecutor

Is it possible (and if so: how) to add a user task to an executive in BPM? My requirement is to execute a process-related timer or cycle service. I do not want to simulate this in bpmn directly, since this is not part of the process. I could run additional arbitrary processes containing only one async Service task to archive this, but I would prefer to add the Soap / Rest / rmi call to the job queue directly without extra effort. Has anyone tried this before?

+4
source share
1 answer

This is an extended question. It is possible to create a task using the internal API. You need to provide two things:

Custom Job Handler:

public class CustomjobHandler implements JobHandler { public static final String TYPE = "customjobHandler"; public String getType() { return TYPE; } public void execute(String configuration, ExecutionEntity execution, CommandContext commandContext) { // provide custom job execution logic } } 

A job handler is added to the process engine configuration. See ( customJobHandlers list).

Team to create a task

For example, from a Java delegate (you can also use a custom command).

 public class CreateJobCommand implements Command<String> { public String execute(CommandContext commandContext) { MessageEntity message = new MessageEntity(); message.setJobHandlerType(CustomJobHandler.TYPE); String config = "some string you want to pass to the hanlder"; message.setJobHandlerConfiguration(config); Context .getCommandContext() .getJobManager() .send(message); return message.getId(); } } 

This creates a "Message Entity" that runs as soon as possible. If you want to execute time on time, you can create TimerEntity. You can then execute the command in the process executor of the process engine.

Edit: to test this in a standalone engine, you must add CustomJobHandler to camunda.cfg.xml:

 <property name="customJobHandlers"> <list> <bean class="<FQN of CustomJobHandler>" /> </list> </property> 
+6
source

Source: https://habr.com/ru/post/1501080/


All Articles