Klaus
Klaus

Reputation: 2396

Camel Recpient List and File/FTP Polling

I need to write a Camel route that poll a tones of ftp servers. The situation is pretty much the one described in this thread: http://web.archiveorange.com/archive/v/kuUDzQRmQQIof5y9zXzG

I am using Spring DSL and I don't seem to be able to piece things together. How are the templates mentioned in that thread relevant?

Even with the file protocol, I wasn't lucky. here is what i tried to create:

<from uri="file://C:/Temp?consumer.delay=1000"/>
            <recipientList parallelProcessing="true" delimiter=",">
                <simple>file://C:/Sampa?consumer.delay=1000</simple>
            </recipientList>

I keep getting an error:

Unknown file language syntax: //C:/Sampa?consumer.delay=1000

Any suggestion? Ideally, a simple route that uses recipient list and file or ftp would be much appreciated.

Upvotes: 0

Views: 1362

Answers (1)

Peter Keller
Peter Keller

Reputation: 7646

The expression in between the <recipientList/> tag must return the URI of the different recipients. In your case your <simple/> tag is constant and in fact not a reasonable URI that's why you get the Unknown file language syntax: //C:/Sampa?consumer.delay=1000 error message.

A good approach is to use header that can be dynamically updated such as

<route>
    <from uri="file:src/data2?noop=true"/>
    <recipientList parallelProcessing="true" delimiter=",">
        <header>myHeader</header>
    </recipientList>
</route>

Find more information about the recipient list pattern here.

EDIT:

The recipientList/> is only used for the dynamic distribution of a message in a route to different targets. If you need to dynamically define sources such as different file directories or FTP servers, then you may setup the routes dynamically using Camel's Java API

pzbkuc class DynamicRouteBuilder extends RouteBuilder {

    private final String[] fileNames;

    public DynamicRouteBuilder(final String[] fileNames) {
        this.fileNames = fileNames;
    }

    @Override
    public void configure() {
        for (final String fileName : this.fileNames) {
            from("file:" + fileName).to("file:targetDirectory");
        }
    }

}

Upvotes: 1

Related Questions