File Processing in Apache Camel

Let me begin with this statement: “Camel is very powerful and very flexible.” Having said that, I believe I am not there yet or Camel is not there yet. Although myself and Camel are not in superb terms with each other, I started to fall in love with it. Lets look at its File Processing Capabilities.Keep looking at this post for updates.

As mentioned in my earlier post, it is very easy to create a file poller over a location. The syntax is

<camel:from uri=”file:src/data?noop=true”/>

It is this one line when put in a route will start polling the folder and will keep on executing the route for each file found in the location.

Here are a few snippets I have found useful regards to this file processing.

1. Get the name of the current file that is being processed.

${in.header.CamelFileName}

But this has to be handled in a language like simple. For example,I wanted to get control over the file name and detect if the file name contained some text, so I used,

<choice>
<when>
<simple>${in.header.CamelFileName} contains “Auto”</simple>

<!– Do something here –>

</choice>

Leave a comment