1

I have a Mule flow which processes files in an inbound folder that are named AAA_[id_number].dat. However, I need to configure Mule to only process this file when a corresponding file named [id_number].dat is also available. The second file indicates that the first is ready for processing.

Is there a way I can configure an inbound endpoint in Mule to only start processing the AAA_ file when it's counterpart is present? The [id_number].dat file is purely for notification purposes, it should not be processed by Mule. The inbound endpoint has a regex filter to look for a file in the format AAA...

<!-- Mule Requester Config -->
<mulerequester:config name="muleRequesterConfig" doc:name="Mule Requester"/>

<!-- File Connectors -->
<file:connector name="inputTriggerConnector" pollingFrequency="100" doc:name="File"/>
<file:connector name="inputFileConnector" doc:name="File"/>
<file:connector name="outputFileConnector" doc:name="File"/>

<!-- File Endpoints -->
<file:endpoint name="inputFileEndpoint" path="src/test/input" responseTimeout="10000" doc:name="File">
    <file:filename-regex-filter pattern="\d{6}.dat" caseSensitive="true"/>  
</file:endpoint>

<!-- Trigger Flow -->
<flow name="triggerFlow" doc:name="triggerFlow">

    <file:inbound-endpoint ref="inputFileEndpoint" connector-ref="inputTriggerConnector" pollingFrequency="1000" doc:name="Input Trigger"/>

    <flow-ref name="mainFlow_StockB2C" doc:name="Flow Reference"/>       

</flow>

<!-- Main Flow -->
<flow name="mainFlow" doc:name="mainFlow">

    <mulerequester:request config-ref="muleRequesterConfig" resource="file://.../AAA_#[message.inboundProperties.originalFilename]?connector=inputFileConnector" timeout="6000" doc:name="Mule Requester"/>

    <DO SOMETHING WITH AAA_ FILE>

    <file:outbound-endpoint connector-ref="outputFileConnector" path="src/test/output" outputPattern="#[function:dateStamp].csv" responseTimeout="6000" doc:name="Output File"/>

</flow>
danw
  • 1,608
  • 4
  • 29
  • 48

2 Answers2

2

Why not filter set a file inbound filter for the [id_number].dat files (or one that excludes the AAA_ files), if those are only used for notification? Would make more sense in my opinion. You can then grab the file to be processed with the requester module inside the flow, based on the originalFileName property.

Anton Kupias
  • 3,945
  • 3
  • 16
  • 20
  • Thanks @Anton, I hadn't thought of that. – danw Mar 05 '14 at 09:06
  • Hi @Anton, I have a follow up question. How do I stop Mule from processing the [id_number].dat file? I only want the file with the AAA prefix to be processed by my flow. Currently if I drop the [id_number] file in my inbound location first it is processed and the AAA file is left untouched. I've edited my original question to include my XML. – danw Mar 05 '14 at 16:46
  • Sorry, I don't understand your question. Your xml is not runnable due to small mistakes and missing code, but apart from that it looks mostly like it should. The content of [id_number] file is largely ignored, and at the point you should have the AAA file content available. You should see the file contents if you put after the mulerequester component. – Anton Kupias Mar 05 '14 at 21:40
  • currently if [id_number] is placed in the input directory before AAA_[id_number] then it is passed through the flow and into the output directory, so when an AAA_[id_number] file is dropped, nothing happens to it. I'm trying to prevent the [id_number] file from progressing past the first 'trigger' flow and remaining in the input directory until AAA_ appears. – danw Mar 06 '14 at 09:26
  • That scenario doesn't quite match the "second file indicates that the first is ready for processing" description... I suggest you try to set up until-successful or some exception strategy to retry periodically when the AAA file is not available. – Anton Kupias Mar 06 '14 at 09:34
0

Just in case this might help someone who needs it, you can create a custom filter and include your own filtering logic in there. More details from this blog here

Ayodeji
  • 579
  • 2
  • 8
  • 25