I'm having some issues with making async jBPM custom tasks within my bpm process. My custom task relies on my CustomTaskHandler class that looks something like this
@RequiredArgsConstructor
@Component("CustomSpringTask")
public class CustomTaskHandler implements WorkItemHandler {
private final RuntimeDataServiceBase runtimeDataServiceBase;
private final MeterRegistry meterRegistry;
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
//new Thread(() -> executeLogic(workItem, manager)).start();
executeLogic(workItem, manager);
}
public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
manager.abortWorkItem(workItem.getId());
}
}
SN: I clearly tried the Thread path but it's not a solution I can use in my use case
This works perfectly fine when using normal non-async tasks. However when making a task async, the application logs this line before calling the executeWorkItem
2021-07-28 12:27:44,641 [WARN ] org.jbpm.workflow.instance.node.AsyncEventNodeInstance - No async executor service found continuing as sync operation...
This is probably due to the fact that I never created an Executor service. I've opened the default AsyncWorkItemHandler
that uses the ExecutorService
class to schedule the command execution.
So I have 2 doubts:
On the second point then I may ask what is the CommandClass that is required by the ExecutorService, and where to instantiate this ExecutorService and on which class it depends.
I found little to no documentation about it on internet. If anyone could point me out to a plausible solution or documentation that would be great
Right now my project is using this setup:
JBpm requires ExecuterService to run async tasks. if you're using kie group provided spring boot starters then you can simply enable the executor by setting this property in your application.properties file.
jbpm.executor.enabled=true
more about jbpm's async execution here
checkout spring-boot-starter for jbpm at github