2
votes

Below is my file inbound endpoint configuration. It is processing all .edi files available at the specified path.

<file:inbound-endpoint path="D:\test docs\in" pollingFrequency="3000" responseTimeout="10000" doc:name="Incoming File">

<file:filename-regex-filter pattern="(.*).edi" caseSensitive="false" />

I send an event to this endpoint from spring application as below

muleClient.dispatch("file://D:/test docs/in", inputFileName, null);

I am passing the input file name as message1.edi. I want to restrict file inbound point to process single file whose name is sent as payload object in dispatch().

Is it possible with file inbound endpoint?

Muleclient.dispatch() is an async method. I want to pause the current thread till i get reply from dispatch(). As of now i am using thread.sleep(). Is there any better approach?

3

3 Answers

2
votes

I may be missing the point :-) however I don't think the dispatch is what you want to use. To trigger the event on the mule file listener, copy your message1.edi to the file folder file://D:/test docs/in

mule will pickup the file and process.

Alternativly, I don't think the mule file endpoint support dynamically changing the regex, if you want to dynamically change the file then trigger your flow with muleClient.dispatch("file://D:/test docs/in", inputFileName, null); and use a groovy component to read an process the file named in the trigger

def fileContent = new File("file://D:/test docs/in/" + inputFileName).text
return fileContent

Adjust according if not text files.

1
votes

There is no need for an inbound endpoint. You need to use a the request method of the MuleClient to get a custom file content on demand:

muleClient.request('file://D:/test docs/in', -1);
0
votes

sorry i could have posted the whole mule flow code. Below is my mule flow:

<flow name="ediTransformationFlow" doc:name="ediTransformationFlow"> <file:inbound-endpoint path="D:\smooks\test docs\in" pollingFrequency="3000" responseTimeout="10000" doc:name="Incoming File" transformer-refs="SmooksTransformer" moveToDirectory="D:\smooks\test docs\history" moveToPattern="#[header:originalFilename]">
<file:filename-regex-filter pattern="(.*).edi" caseSensitive="false" /> </file:inbound-endpoint> <file:outbound-endpoint path="D:\smooks\test docs\out" responseTimeout="10000" doc:name="Outgoing File" outputPattern="#[header:originalFilename].xml"/>
</flow>

My requirement is: From spring controller I will send .edi file name to file inbound endpoint. It will read the file from D:\smooks\test docs\in folder, transforms it to xml file. File outbound end point places the xml file in D:\smooks\test docs\out folder. In spring controller i should be able to read the xml file and create a dom source.

xmlDocument = builder.parse(documentRootPath + outputFileName); Source source = new DOMSource(xmlDocument);

To request mule from spring controller i am using mule client

muleClient.dispatch("file://D:/smooks/test docs/in", inputFileName,null); message = muleClient.request("file://D:/smooks/test docs/out", 100000);