camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Reading a file once
Date Wed, 29 Apr 2009 14:01:59 GMT

What you want to do is a polling consumer from within a route.

If you look at the link above there are some samples that does what you want.
But they are based on Camel 2.0 but it will give you an idea of how
its possible.

Another new feature in Camel 2.0 is improved enrich so you can enrich
an existing message and merge the result in an aggregation strategy.

But as you are on Camel 1.x what you need to do is to use a processor
as you code and then with the Camel API create a PollingConsumer and
use the receive method to get the file.

I remember there is a Camel 1.x sample on the FTP component page
See the section: Consuming a remote FTP server triggered by a route

On Wed, Apr 29, 2009 at 2:52 PM, G.J. van de Streek <> wrote:
> When a timer goes off I want to call a webservice, store the results, then
> read a file from disk somewhere and ...etc. Is it possible to read a file
> from disk just once, not creating a polling consumer on it. I've tried
> something like:
>    Endpoint cacheEndpoint = endpoint("file://directory/");
>    Processor localFileProcessor = new LocalFileProcessor();
>        from(getTimerUri())
>                .to("http://...")
>                .to("direct:savePortalsFile")
>                .setHeader(FileComponent.HEADER_FILE_NAME,
> constant("agents.xml"))
>                .process(localFileProcessor)
>                .to("log:domeo.integration?level=INFO")
>                ;
>    private class LocalFileProcessor implements Processor {
>        public void process(Exchange exchange) throws Exception {
>            Exchange fileExchange = cacheEndpoint.createExchange();
>            Message inFile = fileExchange.getIn();
>            exchange.setIn(inFile);
>        }
>    }
> If the cacheEndpoint is a file, this works, but if it is a directory, it is
> not picking up the HEADER_FILE_NAME. Is this the right approach? Is this
> custom processor a reasonable implementation or does anyone have other
> suggestions?
> --
> View this message in context:
> Sent from the Camel - Users (activemq) mailing list archive at

Claus Ibsen
Apache Camel Committer

Open Source Integration:
Apache Camel Reference Card:

View raw message