Reputation: 37
I have a text file in a specific directory. I have to read the contents of the file and make an API call for that.
But getting the below message
org.mule.routing.ExpressionSplitter: The expression does not evaluate to a type that can be split: [B
Below is the mule xml content. Can someone please help me?
<file:connector name="File_Input" autoDelete="false" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="testxmlFlow1" doc:name="testxmlFlow1">
<file:inbound-endpoint path="C:\mule_program_test\input" responseTimeout="10000" doc:name="File" moveToPattern="data.txt" connector-ref="File_Input"></file:inbound-endpoint>
<file:file-to-byte-array-transformer doc:name="File to Byte Array"/>
<foreach doc:name="For Each" collection="#[payload]">
<logger message="Messagesssssssssssssss" level="INFO" doc:name="Logger"/>
</foreach>
</flow>
Upvotes: 0
Views: 2644
Reputation: 2475
You don't need to use a foreach to process each file in turn, because the file connector generates a message for each file it discovers in the directory. Your flow will run for every file that is placed in that directory.
Also, the file connector monitors the directory by checking for new files every so often, according to its pollingFrequency. Since you haven't specified one, I think the default is 1000ms, which means it will process all the files in the directory once every second. Additionally, you have configured autoDelete="false" and have not configured a moveToDirectory. This means the files will remain in the directory C:\mule_program_test\input after being processed, and so they will be processed again every polling cycle.
If you want to process each file just once, use moveToDirectory and/or autoDelete to make sure it is not processed again on the next polling cycle.
Upvotes: 1