You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Claus Ibsen <ci...@silverbullet.dk> on 2008/06/23 10:33:25 UTC

FileProducer - Some strange code

Hi

In the file component (FileProducer)

FileProducer (for writing files) has some strange code:

  public void process(FileExchange exchange) throws Exception {
        if (ExchangeHelper.isOutCapable(exchange)) {
            // lets poll the file
            Message out = exchange.getOut(true);
            endpoint.configureMessage(endpoint.getFile(), out);
            return;
        }

        ...
        Normal code to do the writing of the in body


The code above will for all Out capable exchanges (eg InOut) poll a file instead.

I haven't digged deeper yet, but I wanted to hear if anyone knows the reason for this code.

See the unit test in camel-jetty component HttpToFileTest that demonstrates a user request on the forum how to save http requests to files.
I needed to change the exchange pattern to in only to avoid the strange code above to kick in.

As I haven't had my 3rd cup of morning coffee yet I am in a state where I can't read the code to well to understand the holy reason for it ;)


See also user forum for the user request:
http://www.nabble.com/from-http%3A--...-to-file%3A--...-td17739149s22882.html


Med venlig hilsen

Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk


Re: FileProducer - Some strange code

Posted by James Strachan <ja...@gmail.com>.
2008/6/23 Claus Ibsen <ci...@silverbullet.dk>:
> Hi
>
> In the file component (FileProducer)
>
> FileProducer (for writing files) has some strange code:
>
>  public void process(FileExchange exchange) throws Exception {
>        if (ExchangeHelper.isOutCapable(exchange)) {
>            // lets poll the file
>            Message out = exchange.getOut(true);
>            endpoint.configureMessage(endpoint.getFile(), out);
>            return;
>        }
>
>        ...
>        Normal code to do the writing of the in body
>
>
> The code above will for all Out capable exchanges (eg InOut) poll a file instead.
>
> I haven't digged deeper yet, but I wanted to hear if anyone knows the reason for this code.
>
> See the unit test in camel-jetty component HttpToFileTest that demonstrates a user request on the forum how to save http requests to files.
> I needed to change the exchange pattern to in only to avoid the strange code above to kick in.
>
> As I haven't had my 3rd cup of morning coffee yet I am in a state where I can't read the code to well to understand the holy reason for it ;)
>
>
> See also user forum for the user request:
> http://www.nabble.com/from-http%3A--...-to-file%3A--...-td17739149s22882.html

I'm still only midway through my first cup :) I've got a hazy memory
of it being to do with file polling; but then I'd have thought this
would have been in the consumer not the producer side?

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com