🎡Executor method
You can inject FlowExecutor
in any Spring boot/Spring context managed class.
FlowExecutor
has several overloaded methods.
# Return type is LiteflowResponse
//The parameter is the chain ID, there is no initial process input parameter, and the context type is the default DefaultContext
public LiteflowResponse execute2Resp(String chainId)
//The first parameter is the chain ID, and the second parameter is the chain input parameter. The context type is the default DefaultContext
public LiteflowResponse execute2Resp(String chainId, Object param);
//The first parameter is the chain ID, the second parameter is the chain input parameter, and multiple context classes can be passed in later
public LiteflowResponse execute2Resp(String chainId, Object param, Class<?>... contextBeanClazzArray)
suggestion
The official only recommends that you use the third method. The first two are the default contexts and can be used in test scenarios. Try not to use the default contexts in production scenarios.
# Return type is Future
public Future<LiteflowResponse> execute2Future(String chainId, Object param, Class<?>... contextBeanClazzArray)
If you call this method, it is non-blocking. If you want to get the response, please use future.get().
The number of threads and thread pools of the executor in this mode can also be customized. The specific configuration is as follows. LiteFlow has set preset values, and you can also define them yourself.
liteflow.main-executor-works=64
liteflow.main-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultMainExecutorBuilder
If you define a custom thread pool, you need to create a new class and implement the ExecutorBuilder
interface:
public class CustomThreadBuilder implements ExecutorBuilder {
@Override
public ExecutorService buildExecutor() {
return Executors.newCachedThreadPool();
}
}
Help us improve this document (opens new window)
last update: 2022/10/13, 00:02:27