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) {
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>
source share