camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Müller <christian.muel...@gmail.com>
Subject Re: Reading a file
Date Sun, 27 Jan 2013 16:42:06 GMT
Why no using a consumer template [1]?
For the transformation, I would use a custom type converter [2].

Than you could do something like:
YourCustomBean bean =
receiveBodyNoWait("file://...?fileName=foo.txt&noop=true",
YourCustomBean.class);

or if you need to access the exchange:
Exchange exchange = receiveNoWait("file://...?fileName=foo.txt&noop=true");
if (exchange != null) {
    YourCustomBean bean = exchange.getIn().getBody(YourCustomBean.class);
}

Isn't it simple?

[1] camel.apache.org/polling-consumer.html
[2] http://camel.apache.org/type-converter.html

Best,
Christian

On Sun, Jan 27, 2013 at 2:55 PM, helander <lehswe@gmail.com> wrote:

> I am trying to find a way to do:
>
> From a Producer Template send a request to a route, and in the route I
> would
> like to read the contents of a file, transform the contents and return back
> to the producer template.
> Location and name of file is fixed and the file should not be moved/removed
> by the route.
> If the specified file does not exist, the exchange should return without
> waiting for the file to appear.
> I tried using enrich/pollEnrich, but it seemed like I ended up having
> produced a file with the contents of the inBody.
>
> Any suggestions on how to do this?
>
> Thanks
>
> Lars
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Reading-a-file-tp5726376.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message