You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cmoulliard <cm...@gmail.com> on 2009/03/30 15:14:41 UTC

headers removed when moving to a queue (Camel 2.0) ??

Hi,

I would like to know if I do something wrong or is it a bug ?

In the following route, a header is created to define the origin of the
route, the header is well added in first steps of the process (this is
confirmed by the trace) but lost when the message go the queue ?

			<camel:from uri="cxf:bean:reportIncident" />
			<camel:setHeader headerName="origin">
				<camel:constant>webservice</camel:constant>
			</camel:setHeader>
			<camel:convertBodyTo
type="org.apache.camel.example.reportincident.InputReportIncident" />
			<camel:to uri="bean:webservice" />
			<camel:inOnly uri="queuingservice:queue:in" />
			<camel:transform>
				<camel:method bean="feedback" method="setOk" />
			</camel:transform>

convertBodyTo() --> to(bean:webservice), Pattern:InOut, ... ,
Headers:{content-type=text/xml;charset=UTF-8, operationName=ReportIncident,
content.type=text/xml;charset=UTF-8, Host=localhost:8080,
Content-Length=640,
SOAPAction="http://reportincident.example.camel.apache.org/ReportIncident",
origin=webservice, User-Agent=Jakarta Commons-HttpClient/3.1,
operationNameSpace=http://reportincident.example.camel.apache.org,
org.apache.cxf.headers.Header.list=[]}, ...

no more headers here !!! except properties and body

to(bean:webservice) --> inOnly(queuingservice:queue:in), Pattern:InOut, ...,
BodyType:java.util.ArrayList,
Body:[{org.apache.camel.example.reportincident.model.Incident=org.apache.camel.example.reportincident.model.Incident@1f93f8[

Is it a bug a bad configuration of me ?

Regards,

Charles

-----
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: http://www.nabble.com/headers-removed-when-moving-to-a-queue-%28Camel-2.0%29----tp22782917p22782917.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: headers removed when moving to a queue (Camel 2.0) ??

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Can you show the method signature of your bean? (bean:webservice)


On Mon, Mar 30, 2009 at 3:14 PM, cmoulliard <cm...@gmail.com> wrote:
>
> Hi,
>
> I would like to know if I do something wrong or is it a bug ?
>
> In the following route, a header is created to define the origin of the
> route, the header is well added in first steps of the process (this is
> confirmed by the trace) but lost when the message go the queue ?
>
>                        <camel:from uri="cxf:bean:reportIncident" />
>                        <camel:setHeader headerName="origin">
>                                <camel:constant>webservice</camel:constant>
>                        </camel:setHeader>
>                        <camel:convertBodyTo
> type="org.apache.camel.example.reportincident.InputReportIncident" />
>                        <camel:to uri="bean:webservice" />
>                        <camel:inOnly uri="queuingservice:queue:in" />
>                        <camel:transform>
>                                <camel:method bean="feedback" method="setOk" />
>                        </camel:transform>
>
> convertBodyTo() --> to(bean:webservice), Pattern:InOut, ... ,
> Headers:{content-type=text/xml;charset=UTF-8, operationName=ReportIncident,
> content.type=text/xml;charset=UTF-8, Host=localhost:8080,
> Content-Length=640,
> SOAPAction="http://reportincident.example.camel.apache.org/ReportIncident",
> origin=webservice, User-Agent=Jakarta Commons-HttpClient/3.1,
> operationNameSpace=http://reportincident.example.camel.apache.org,
> org.apache.cxf.headers.Header.list=[]}, ...
>
> no more headers here !!! except properties and body
>
> to(bean:webservice) --> inOnly(queuingservice:queue:in), Pattern:InOut, ...,
> BodyType:java.util.ArrayList,
> Body:[{org.apache.camel.example.reportincident.model.Incident=org.apache.camel.example.reportincident.model.Incident@1f93f8[
>
> Is it a bug a bad configuration of me ?
>
> Regards,
>
> Charles
>
> -----
> Charles Moulliard
> SOA Architect
>
> My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/
> --
> View this message in context: http://www.nabble.com/headers-removed-when-moving-to-a-queue-%28Camel-2.0%29----tp22782917p22782917.html
> Sent from the Camel - Users 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

Re: headers removed when moving to a queue (Camel 2.0) ??

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Could be inOnly() not propagating headers.
Let me take a look.


On Mon, Mar 30, 2009 at 3:14 PM, cmoulliard <cm...@gmail.com> wrote:
>
> Hi,
>
> I would like to know if I do something wrong or is it a bug ?
>
> In the following route, a header is created to define the origin of the
> route, the header is well added in first steps of the process (this is
> confirmed by the trace) but lost when the message go the queue ?
>
>                        <camel:from uri="cxf:bean:reportIncident" />
>                        <camel:setHeader headerName="origin">
>                                <camel:constant>webservice</camel:constant>
>                        </camel:setHeader>
>                        <camel:convertBodyTo
> type="org.apache.camel.example.reportincident.InputReportIncident" />
>                        <camel:to uri="bean:webservice" />
>                        <camel:inOnly uri="queuingservice:queue:in" />
>                        <camel:transform>
>                                <camel:method bean="feedback" method="setOk" />
>                        </camel:transform>
>
> convertBodyTo() --> to(bean:webservice), Pattern:InOut, ... ,
> Headers:{content-type=text/xml;charset=UTF-8, operationName=ReportIncident,
> content.type=text/xml;charset=UTF-8, Host=localhost:8080,
> Content-Length=640,
> SOAPAction="http://reportincident.example.camel.apache.org/ReportIncident",
> origin=webservice, User-Agent=Jakarta Commons-HttpClient/3.1,
> operationNameSpace=http://reportincident.example.camel.apache.org,
> org.apache.cxf.headers.Header.list=[]}, ...
>
> no more headers here !!! except properties and body
>
> to(bean:webservice) --> inOnly(queuingservice:queue:in), Pattern:InOut, ...,
> BodyType:java.util.ArrayList,
> Body:[{org.apache.camel.example.reportincident.model.Incident=org.apache.camel.example.reportincident.model.Incident@1f93f8[
>
> Is it a bug a bad configuration of me ?
>
> Regards,
>
> Charles
>
> -----
> Charles Moulliard
> SOA Architect
>
> My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/
> --
> View this message in context: http://www.nabble.com/headers-removed-when-moving-to-a-queue-%28Camel-2.0%29----tp22782917p22782917.html
> Sent from the Camel - Users 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

Re: headers removed when moving to a queue (Camel 2.0) ??

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Mar 30, 2009 at 4:40 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> The problem lies with the bean component. It does not propagate the
> headers. And it depends how you have defined the methods signature as
> well.
> If you uses Exchange as parameter then its YOU in charge and you must
> put the headers you want to keep on the OUT message, or eg just alter
> the body of the IN message and keep OUT = null.
>
> But if you use a method signature with a body payload, eg
>
>        public String confirmOrder(int id) {
>            return "Order OK for id: " + id;
>        }
>
> Where the int id is the IN body converted to a String.
> Then Camel does infact not propagte the headers.
>
> I think it should. If you need to clear the headers etc then pass in
> @Headers Map as a parameter and adjust them as you like.
> Or use the removeHeader DSL.

Ticket CAMEL-1502 tracks this bug.

Re: headers removed when moving to a queue (Camel 2.0) ??

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

The problem lies with the bean component. It does not propagate the
headers. And it depends how you have defined the methods signature as
well.
If you uses Exchange as parameter then its YOU in charge and you must
put the headers you want to keep on the OUT message, or eg just alter
the body of the IN message and keep OUT = null.

But if you use a method signature with a body payload, eg

        public String confirmOrder(int id) {
            return "Order OK for id: " + id;
        }

Where the int id is the IN body converted to a String.
Then Camel does infact not propagte the headers.

I think it should. If you need to clear the headers etc then pass in
@Headers Map as a parameter and adjust them as you like.
Or use the removeHeader DSL.






On Mon, Mar 30, 2009 at 4:34 PM, Willem Jiang <wi...@gmail.com> wrote:
> Hi Charles,
>
> Maybe you should attach the code of "bean:webservices".
> I just went through the code that you sent to me last week, and hope you
> don't changed much of them.
>
> Here are the code snippet
>
>
>        // Get Header origin from message
>        String origin = (String) exchange.getIn().getHeader("origin");
>
>        // Specify current Date
>        String currentDate = format.format( new Date() );
>        Date creationDate = format.parse( currentDate );
>
>        incident.setCreationDate(creationDate);
>        incident.setCreationUser(origin);
>
>        // and place it in a model (cfr camel-bindy)
>        model.put(Incident.class.getName(), incident);
>        models.add(model);
>
>        /**You need to copy the headers of in message to out message
> like this**/
>        exchange.getOut().setHeaders(exchange.getIn().getHeaders());
>
>        // replace with our input
>        exchange.getOut().setBody(models);
>
>
> Willem
>
>
> cmoulliard wrote:
>> Willem,
>>
>> Is it mandatory to copy the header to the out message in a bean ?
>>
>> What I do in the bean is to read my header like this :
>> exchange.getIn().getHeader("origin");
>>
>> How do you explain that the headers list is completely empty ?
>>
>> Regards,
>>
>> charles
>>
>>
>>
>> willem.jiang wrote:
>>> Hi Charles,
>>>
>>> Maybe you forget to copy the message header from the in message to out
>>> message in "bean:webservices".
>>>
>>> Willem
>>>
>>> cmoulliard wrote:
>>>> Hi,
>>>>
>>>> I would like to know if I do something wrong or is it a bug ?
>>>>
>>>> In the following route, a header is created to define the origin of the
>>>> route, the header is well added in first steps of the process (this is
>>>> confirmed by the trace) but lost when the message go the queue ?
>>>>
>>>>                     <camel:from uri="cxf:bean:reportIncident" />
>>>>                     <camel:setHeader headerName="origin">
>>>>                             <camel:constant>webservice</camel:constant>
>>>>                     </camel:setHeader>
>>>>                     <camel:convertBodyTo
>>>> type="org.apache.camel.example.reportincident.InputReportIncident" />
>>>>                     <camel:to uri="bean:webservice" />
>>>>                     <camel:inOnly uri="queuingservice:queue:in" />
>>>>                     <camel:transform>
>>>>                             <camel:method bean="feedback" method="setOk" />
>>>>                     </camel:transform>
>>>>
>>>> convertBodyTo() --> to(bean:webservice), Pattern:InOut, ... ,
>>>> Headers:{content-type=text/xml;charset=UTF-8,
>>>> operationName=ReportIncident,
>>>> content.type=text/xml;charset=UTF-8, Host=localhost:8080,
>>>> Content-Length=640,
>>>> SOAPAction="http://reportincident.example.camel.apache.org/ReportIncident",
>>>> origin=webservice, User-Agent=Jakarta Commons-HttpClient/3.1,
>>>> operationNameSpace=http://reportincident.example.camel.apache.org,
>>>> org.apache.cxf.headers.Header.list=[]}, ...
>>>>
>>>> no more headers here !!! except properties and body
>>>>
>>>> to(bean:webservice) --> inOnly(queuingservice:queue:in), Pattern:InOut,
>>>> ...,
>>>> BodyType:java.util.ArrayList,
>>>> Body:[{org.apache.camel.example.reportincident.model.Incident=org.apache.camel.example.reportincident.model.Incident@1f93f8[
>>>>
>>>> Is it a bug a bad configuration of me ?
>>>>
>>>> Regards,
>>>>
>>>> Charles
>>>>
>>>> -----
>>>> Charles Moulliard
>>>> SOA Architect
>>>>
>>>> My Blog :  http://cmoulliard.blogspot.com/
>>>> http://cmoulliard.blogspot.com/
>>>
>>>
>>
>>
>> -----
>> Charles Moulliard
>> SOA Architect
>>
>> My Blog :  http://cmoulliard.blogspot.com/ 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

Re: headers removed when moving to a queue (Camel 2.0) ??

Posted by Willem Jiang <wi...@gmail.com>.
Hi Charles,

Maybe you should attach the code of "bean:webservices".
I just went through the code that you sent to me last week, and hope you
don't changed much of them.

Here are the code snippet


        // Get Header origin from message
        String origin = (String) exchange.getIn().getHeader("origin");

        // Specify current Date
        String currentDate = format.format( new Date() );
        Date creationDate = format.parse( currentDate );

        incident.setCreationDate(creationDate);
        incident.setCreationUser(origin);

        // and place it in a model (cfr camel-bindy)
        model.put(Incident.class.getName(), incident);
        models.add(model);

        /**You need to copy the headers of in message to out message
like this**/
        exchange.getOut().setHeaders(exchange.getIn().getHeaders());

        // replace with our input
        exchange.getOut().setBody(models);


Willem


cmoulliard wrote:
> Willem,
> 
> Is it mandatory to copy the header to the out message in a bean ?
> 
> What I do in the bean is to read my header like this :
> exchange.getIn().getHeader("origin");
> 
> How do you explain that the headers list is completely empty ?
> 
> Regards,
> 
> charles
> 
> 
> 
> willem.jiang wrote:
>> Hi Charles,
>>
>> Maybe you forget to copy the message header from the in message to out
>> message in "bean:webservices".
>>
>> Willem
>>
>> cmoulliard wrote:
>>> Hi,
>>>
>>> I would like to know if I do something wrong or is it a bug ?
>>>
>>> In the following route, a header is created to define the origin of the
>>> route, the header is well added in first steps of the process (this is
>>> confirmed by the trace) but lost when the message go the queue ?
>>>
>>> 			<camel:from uri="cxf:bean:reportIncident" />
>>> 			<camel:setHeader headerName="origin">
>>> 				<camel:constant>webservice</camel:constant>
>>> 			</camel:setHeader>
>>> 			<camel:convertBodyTo
>>> type="org.apache.camel.example.reportincident.InputReportIncident" />
>>> 			<camel:to uri="bean:webservice" />
>>> 			<camel:inOnly uri="queuingservice:queue:in" />
>>> 			<camel:transform>
>>> 				<camel:method bean="feedback" method="setOk" />
>>> 			</camel:transform>
>>>
>>> convertBodyTo() --> to(bean:webservice), Pattern:InOut, ... ,
>>> Headers:{content-type=text/xml;charset=UTF-8,
>>> operationName=ReportIncident,
>>> content.type=text/xml;charset=UTF-8, Host=localhost:8080,
>>> Content-Length=640,
>>> SOAPAction="http://reportincident.example.camel.apache.org/ReportIncident",
>>> origin=webservice, User-Agent=Jakarta Commons-HttpClient/3.1,
>>> operationNameSpace=http://reportincident.example.camel.apache.org,
>>> org.apache.cxf.headers.Header.list=[]}, ...
>>>
>>> no more headers here !!! except properties and body
>>>
>>> to(bean:webservice) --> inOnly(queuingservice:queue:in), Pattern:InOut,
>>> ...,
>>> BodyType:java.util.ArrayList,
>>> Body:[{org.apache.camel.example.reportincident.model.Incident=org.apache.camel.example.reportincident.model.Incident@1f93f8[
>>>
>>> Is it a bug a bad configuration of me ?
>>>
>>> Regards,
>>>
>>> Charles
>>>
>>> -----
>>> Charles Moulliard
>>> SOA Architect
>>>
>>> My Blog :  http://cmoulliard.blogspot.com/
>>> http://cmoulliard.blogspot.com/  
>>
>>
> 
> 
> -----
> Charles Moulliard
> SOA Architect
> 
> My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  


Re: headers removed when moving to a queue (Camel 2.0) ??

Posted by cmoulliard <cm...@gmail.com>.
Willem,

Is it mandatory to copy the header to the out message in a bean ?

What I do in the bean is to read my header like this :
exchange.getIn().getHeader("origin");

How do you explain that the headers list is completely empty ?

Regards,

charles



willem.jiang wrote:
> 
> Hi Charles,
> 
> Maybe you forget to copy the message header from the in message to out
> message in "bean:webservices".
> 
> Willem
> 
> cmoulliard wrote:
>> Hi,
>> 
>> I would like to know if I do something wrong or is it a bug ?
>> 
>> In the following route, a header is created to define the origin of the
>> route, the header is well added in first steps of the process (this is
>> confirmed by the trace) but lost when the message go the queue ?
>> 
>> 			<camel:from uri="cxf:bean:reportIncident" />
>> 			<camel:setHeader headerName="origin">
>> 				<camel:constant>webservice</camel:constant>
>> 			</camel:setHeader>
>> 			<camel:convertBodyTo
>> type="org.apache.camel.example.reportincident.InputReportIncident" />
>> 			<camel:to uri="bean:webservice" />
>> 			<camel:inOnly uri="queuingservice:queue:in" />
>> 			<camel:transform>
>> 				<camel:method bean="feedback" method="setOk" />
>> 			</camel:transform>
>> 
>> convertBodyTo() --> to(bean:webservice), Pattern:InOut, ... ,
>> Headers:{content-type=text/xml;charset=UTF-8,
>> operationName=ReportIncident,
>> content.type=text/xml;charset=UTF-8, Host=localhost:8080,
>> Content-Length=640,
>> SOAPAction="http://reportincident.example.camel.apache.org/ReportIncident",
>> origin=webservice, User-Agent=Jakarta Commons-HttpClient/3.1,
>> operationNameSpace=http://reportincident.example.camel.apache.org,
>> org.apache.cxf.headers.Header.list=[]}, ...
>> 
>> no more headers here !!! except properties and body
>> 
>> to(bean:webservice) --> inOnly(queuingservice:queue:in), Pattern:InOut,
>> ...,
>> BodyType:java.util.ArrayList,
>> Body:[{org.apache.camel.example.reportincident.model.Incident=org.apache.camel.example.reportincident.model.Incident@1f93f8[
>> 
>> Is it a bug a bad configuration of me ?
>> 
>> Regards,
>> 
>> Charles
>> 
>> -----
>> Charles Moulliard
>> SOA Architect
>> 
>> My Blog :  http://cmoulliard.blogspot.com/
>> http://cmoulliard.blogspot.com/  
> 
> 
> 


-----
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: http://www.nabble.com/headers-removed-when-moving-to-a-queue-%28Camel-2.0%29----tp22782917p22784102.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: headers removed when moving to a queue (Camel 2.0) ??

Posted by Willem Jiang <wi...@gmail.com>.
Hi Charles,

Maybe you forget to copy the message header from the in message to out
message in "bean:webservices".

Willem

cmoulliard wrote:
> Hi,
> 
> I would like to know if I do something wrong or is it a bug ?
> 
> In the following route, a header is created to define the origin of the
> route, the header is well added in first steps of the process (this is
> confirmed by the trace) but lost when the message go the queue ?
> 
> 			<camel:from uri="cxf:bean:reportIncident" />
> 			<camel:setHeader headerName="origin">
> 				<camel:constant>webservice</camel:constant>
> 			</camel:setHeader>
> 			<camel:convertBodyTo
> type="org.apache.camel.example.reportincident.InputReportIncident" />
> 			<camel:to uri="bean:webservice" />
> 			<camel:inOnly uri="queuingservice:queue:in" />
> 			<camel:transform>
> 				<camel:method bean="feedback" method="setOk" />
> 			</camel:transform>
> 
> convertBodyTo() --> to(bean:webservice), Pattern:InOut, ... ,
> Headers:{content-type=text/xml;charset=UTF-8, operationName=ReportIncident,
> content.type=text/xml;charset=UTF-8, Host=localhost:8080,
> Content-Length=640,
> SOAPAction="http://reportincident.example.camel.apache.org/ReportIncident",
> origin=webservice, User-Agent=Jakarta Commons-HttpClient/3.1,
> operationNameSpace=http://reportincident.example.camel.apache.org,
> org.apache.cxf.headers.Header.list=[]}, ...
> 
> no more headers here !!! except properties and body
> 
> to(bean:webservice) --> inOnly(queuingservice:queue:in), Pattern:InOut, ...,
> BodyType:java.util.ArrayList,
> Body:[{org.apache.camel.example.reportincident.model.Incident=org.apache.camel.example.reportincident.model.Incident@1f93f8[
> 
> Is it a bug a bad configuration of me ?
> 
> Regards,
> 
> Charles
> 
> -----
> Charles Moulliard
> SOA Architect
> 
> My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/