简体   繁体   中英

How to stop/start the Mule flows in multiple applications using Groovy scripting

Is it possible to stop/start the flows which are running across in multiple applications that has been deployed with in the same mule runtime?

Looks we need to write Groovy scripting separately for each applications in order to stop/start. Can somebody help me on this to understand please?

Code snippet:-

  <scripting:component>
     <scripting:script engine="groovy">
        muleContext.registry.lookupFlowConstruct('targetFlow').start()
     </scripting:script>
  </scripting:component>

Here is the description:

muleContext.registry.lookupFlowConstruct(<flowname>).start()

This is the groovy script to start the flow if the process is in stopped condition.'targetFlow' is the name of the flow that you want to start. This is a good practice to check the condition of the process that the process is stopped or started.

If you want to stop the flow you can use below code. this will stop the specified process.

if(muleContext.registry.lookupFlowConstruct(<flowname>).isStarted())
{
muleContext.registry.lookupFlowConstruct(<flowname>).stop();
}
else
{
flowVars.status='Process already in stopped condition';
}

We can start/stop the flows by writing the groovy script within the application and cannot be done across the applications since it is working on the MuleContext basis. Below would be the easier approach.

 <scripting:component>
     <scripting:script engine="groovy">
        muleContext.registry.lookupFlowConstruct('targetFlow').start()
     </scripting:script>
 </scripting:component>

It can be done across applications, wrote a blogpost about this a while ago.

It's using the same commands but then put in an app and exposed via HTTP.

http://www.corralict.nl/how-to-start-stop-mule-flows-from-a-client-over-http/

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