camel-users mailing list archives

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

What you want to do is a polling consumer from within a route.
http://camel.apache.org/polling-consumer.html

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.
http://camel.apache.org/content-enricher.html

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
http://camel.apache.org/ftp.html
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 <streek@avisi.nl> 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: http://www.nabble.com/Reading-a-file-once-tp23295848p23295848.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration

Mime
View raw message