On Fri, Jun 12, 2009 at 1:23 PM, Charles Moulliard<[email protected]> wrote:
> Hi,
>
> I' m a little bit confused about how to propagate headers received in a
> camel bean ?
>
> Here is my example. Is it correct what I do or not
>
>    public Request createRequest(
>           �...@header(value = "messageType") String messageType, --> header
> received
>           �...@header(value = "CamelFileNameOnly") String fileName, --> header
> received
>           �...@body String body, Exchange exchange) {
>
>        // add the request object to the exchange
>        exchange.getOut().setBody(request); --> QUESTION : Is it required or
> the return statement is enough ?
>        exchange.getOut().setHeader("", ); --> QUESTION : Is it required or
> the headers received will be propagated to the OUT automatically
>
>
>        return request;
>    }
Dont mess with the exchange. Just remove it as a parameter and return
the body as Request object.
Then Camel will automatic put it on the right IN or OUT. And preserve
your headers.

When you set an OUT then YOU are in charge of preserving the headers you want.
For instance maybe you do NOT want any headers then dont copy any from the IN.

So doing just:
    public Request createRequest(
            @Header(value = "messageType") String messageType,
            @Header(value = "CamelFileNameOnly") String fileName,
            @Body String body) {
        // Request request = ...
        // populate data on request
        return request;
    }


>
> Regards,
>
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to