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:
- Should I extend the AsyncWorkItemHandler (although I'm concerned on the customizability of the class if I extend it)
- Should I simply replicate the code within it and add the custom parts
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:
- Spring Boot
- 7.52.0 Kie-Server