0
votes

I have a ServiceFlow and a FileFlow. As soon as the ServiceFlow (Flow1) is triggered, FileFlow (Flow2) should take all the files and process them.

Making the initial state as stopped in Flow2 works only for the first time until Mule server started i.e., for the first triggered execution. Once the flow reaches the first trigger, if I try to keep some files in file:inbound-endpoint it starts processing the files.

But my scenario is based on each trigger only, so the second file has to pick the file. Please help me how to control this in Flow2.

I'm using the below code

<flow name="serviceFlow" doc:name="Flow1">
    <http:inbound-endpoint exchange-pattern="request-response"
        host="localhost" port="8081" doc:name="HTTP" contentType="text/xml"
        mimeType="text/xml" />
    <set-payload value="'Started Processing'" doc:name="Set Payload" />
    <async doc:name="Async">
        <expression-component doc:name="Expression">
            app.registry.FileFlow.start();
        </expression-component>
    </async>
</flow>

<flow name="FileFlow" doc:name="Flow2" initialState="stopped" >
    <file:inbound-endpoint responseTimeout="10000" doc:name="File" path="C:\Users\Desktop\IN"/>
    <batch:execute name="businessBatch1" doc:name="Batch Execute"/>
</flow>

Using Mule version: 3.5.1

1

1 Answers

2
votes

What I can suggest you is to put a <expression-component doc:name="Expression">app.registry.FileFlow.stop();</expression-component> at the end of second flow so after the second flow is executed it will again make it's initial state "stopped" so that you can trigger the first flow again without fear since the flow2 is stopped.

<flow name="serviceFlow" doc:name="Flow1">
  <http:inbound-endpoint exchange-pattern="request-response"
        host="localhost" port="8081" doc:name="HTTP" contentType="text/xml"
        mimeType="text/xml" />
  <set-payload value="'Started Processing'" doc:name="Set Payload" />
  <async doc:name="Async">
    <expression-component doc:name="Expression">
      app.registry.FileFlow.start();
    </expression-component>
  </async>
</flow>

<flow name="FileFlow" doc:name="Flow2" initialState="stopped" >
  <file:inbound-endpoint responseTimeout="10000" doc:name="File" path="C:\Users\Desktop\IN"/>
  <batch:execute name="businessBatch1" doc:name="Batch Execute"/>
  <expression-component doc:name="Expression">
    app.registry.FileFlow.stop();
  </expression-component>
</flow>