Reputation: 10707
I have a Mule flow that I'm starting by means of the following script:
muleContext.registry.lookupFlowConstruct('targetFlow').start()
However, I'd like the script to be executed only when the flow is stopped. Is there any way that I can check this in the script before doing the start?
Upvotes: 2
Views: 1709
Reputation: 8311
Alternately you can use Groovy component to check the status and put your simple script as follows :-
<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA[
if(muleContext.registry.lookupFlowConstruct('yourFlowName').isStopped())
{
muleContext.registry.lookupFlowConstruct('yourFlowName').start();
}
return message.payload;
]]>
</scripting:script>
</scripting:component>
Note Groovy script is the easiest way to achieve this
Upvotes: 3
Reputation: 573
You could use this method to validate if the flow is started. I hope help you.
AbstractFlowConstruct f = (AbstractFlowConstruct) muleContext.getRegistry().lookupFlowConstruct("flowName");
if (f.isStopped()){
// start flow
}
// it can also be used : f.isStarted()
Upvotes: 4