title: Start/Stop mule flow programmatically
body: <p>I keep one of my flow say 'flow A' in "stopped" as a initial state. Then in another flow say 'flow B', using groovy script or MEL expression; I am starting the same 'flow A'. At the end of the 'flow A', I am programmatically stopping the flow.</p>
  
  <p>Now, If I again start the 'flow A' through 'flow B' it fails saying 'flow A' is already started; can not be restarted.</p>
  
  <p>Any solution for this. </p>
  
  <p>I want to start my flow any time I want, keeping initial state as stopped &amp; again at the end stopping the flow using script.  </p>
  
  <p>Here is the code: </p>
  
  <pre><code>&lt;flow name="FlowB"&gt;
      &lt;poll doc:name="Poll"&gt;
          &lt;logger level="INFO" doc:name="Logger"/&gt;
      &lt;/poll&gt;
      &lt;logger level="INFO" doc:name="Logger" message="triggered"/&gt;
      &lt;scripting:component doc:name="Groovy"&gt;
          &lt;scripting:script engine="Groovy"&gt;&lt;![CDATA[muleContext.registry.lookupFlowConstruct('FlowB').start()]]&gt;&lt;/scripting:script&gt;
      &lt;/scripting:component&gt;
      &lt;logger level="INFO" doc:name="Logger"/&gt;
      &lt;expression-component doc:name="Expression"&gt;&lt;![CDATA[app.registry.FlowA.stop();]]&gt;&lt;/expression-component&gt;
  &lt;/flow&gt;
  &lt;flow name="FlowA" initialState="stopped"&gt;
      &lt;sqs:receive-messages config-ref="Amazon_SQS__Configuration" doc:name="Amazon SQS (Streaming)"/&gt;
      &lt;logger level="INFO" doc:name="Logger"/&gt;
  &lt;/flow&gt; 
  </code></pre>
  
  <p>I am using poller to start the flow A. So, if I again run the flow B to start the flow A; Its throwing an exception.</p>