0
votes

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>
3

3 Answers

0
votes

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';
}
0
votes

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>
0
votes

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/