You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Charles Moulliard <cm...@gmail.com> on 2009/06/12 13:23:55 UTC
How to propagate headers received in a camel bean ?
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;
}
Regards,
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
Re: How to propagate headers received in a camel bean ?
Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jun 12, 2009 at 1:23 PM, Charles Moulliard<cm...@gmail.com> 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