Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HOW: Apache Camel, Regex match files

im experimenting in getting camel to do some file operations and pass them through the activeMQ broker, ive taken this project over from a guy who recently quit.

what ive got so far:

    <route id="SVLFTPCOPY">
  <from uri="sftp://*****:*******@********/srv/test/?fileName=*2280.xls&amp;noop=true&amp;idempotent=false"/>
    <to uri="file:/srv/data/test/destination/"/>
    <to uri="activemq:queue:svl.ftp.copy"/>
    </route>

it works to the point where it runs the route without throwing any errors, but still doesnt copy the file to the local file.

Any ideas? .

like image 245
ministry Avatar asked Mar 01 '12 13:03

ministry


People also ask

What is Camel file?

The Apache Camel File component is the simplest way to transfer files from a source folder to a destination without any coding required. This tutorial will teach you how to create a Camel application using the File component and how to configure to move (or don't move) the file in the Route.

What is Noop true in Camel?

noop=true" in the "from" call indicates that nothing should be changed about the files in the "input" directory (the processing should have "noop" effect on the source files).

Is Apache Camel middleware?

Apache Camel is an open source framework for message-oriented middleware with a rule-based routing and mediation engine that provides a Java object-based implementation of the Enterprise Integration Patterns using an application programming interface (or declarative Java domain-specific language) to configure routing ...


2 Answers

Yeah you need to use the include/exclude/filter option if you want to filter out files based on patterns. The fileName option is for a single file.

So in your case, remove fileName option and replace it with include=.*2280.xsl. Mind that the include is based on Java regular expressions, so we use dot star to indicate wildcard. More details here: https://camel.apache.org/components/latest/file-component.html. The ftp component inherits 99% of the options of the file component, so that is why I refer to the file wiki page.

like image 114
Claus Ibsen Avatar answered Oct 01 '22 12:10

Claus Ibsen


Use the include option that uses Java regular expression:

include=.*2280\\.xsl

Please, mind the \\ before the dot .

Alternatively, use antInclude:

antInclude=*2280.xsl
like image 27
Peter Keller Avatar answered Oct 01 '22 12:10

Peter Keller