My use case is this: I'm using the async executor. I have some async service tasks and I want to set the thread names for the threads that will be executing these tasks. I guess the same applies for script tasks - I want the thread that executes them to have a specific name. How can I achieve these things?
Solved! Go to Solution.
This would require that you overload the Job Executor service classes.
You can find the necessary classes under here:
Activiti/modules/activiti-engine/src/main/java/org/activiti/engine/impl/asyncexecutor at master · Ac...
Specifically you should look in AbstractAsyncJobExecutor.java
As for script tasks, it may be difficult to name the thread as sometimes the thread will be a servlet thread, sometimes it will be inherited from a previous job (sync continuation) and sometimes it will be picked up from the Job executor (async continuation).
Cheers,
Greg
This would require that you overload the Job Executor service classes.
You can find the necessary classes under here:
Activiti/modules/activiti-engine/src/main/java/org/activiti/engine/impl/asyncexecutor at master · Ac...
Specifically you should look in AbstractAsyncJobExecutor.java
As for script tasks, it may be difficult to name the thread as sometimes the thread will be a servlet thread, sometimes it will be inherited from a previous job (sync continuation) and sometimes it will be picked up from the Job executor (async continuation).
Cheers,
Greg
Thanks for the response! This is what I did:
AbstractAsyncJobExecutor asyncExecutor = new DefaultAsyncJobExecutor();
asyncExecutor.setExecuteAsyncRunnableFactory(MyExecuteAsyncRunnable::new);
processEngineConfiguration.setAsyncExecutor(asyncExecutor);
...
class MyExecuteAsyncRunnable extends ExecuteAsyncRunnable {
public MyExecuteAsyncRunnable(JobEntity job, CommandExecutor commandExecutor) {
super(job, commandExecutor);
}
@Override
public void run() {
Thread.currentThread().setName("asd");
super.run();
}
}
It seems to work correctly - does it look fine though? I don't like that I've hardcoded setting the async executor to be a DefaultAsyncJobExecutor but unfortunately processEngineConfiguration.getAsyncExecutor() returns null. Also, I'm extending the ExecuteAsyncRunnable class while there are others that I could extend - e.g. TenantAwareExecuteAsyncRunnable. Is that also correct? Is there a better way of doing all of those things?
As for the script tasks - you have no ideas how to make sure that all script tasks are executed in a specific thread?
Thanks again!
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.