简体   繁体   中英

How to find out Mule flow status

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?

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()

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM