🥑Implicit chain
LiteFlow supports calling another chain through code in one node, and this chain relationship will not be displayed in the rule file. So here it is called implicit call.
The main chain and the implicit chain share the same context data. So the implicit chain can also get all the data in this request.
Implicit chain can complete more complex sub-processes, such as loop calls, complex conditional judgments, and so on. Implicit chain require you to invoke the this.invoke
statement in the component.
@Component("h")
public class HComponent extends NodeComponent {
@Override
public void process() {
System.out.println("Hcomponent executed!");
for(int i=0;i<10;i++){
this.invoke("strategy1","initial parameters");
}
}
}
This code shows a method of calling another process chain cyclically within a business node.
提示
It should be noted that if you open muti thread in the component to call the implicit component, it is recommended to use the invokeInAsync
method.
Implicit chain also supports returning the LiteFlowResponse
object, you need to call the invoke2Resp
method. For the description of the returned object being LiteFlowResponse
, please refer to LiteflowResponse object.
notice
If you are using invoke
to call an implicit process, get the incoming implicit process request parameters in the component, go through this.getSubChainReqData()
to get them.
If you are using invokeInAsync
to invoke the hard process and get the incoming implicit process request parameters in the component, go through this.getSubChainReqDataInAsync()
to get it.
You can't get it with this.getRequestData()
!