camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: headers removed when moving to a queue (Camel 2.0) ??
Date Mon, 30 Mar 2009 14:40:31 GMT
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 <willem.jiang@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

Mime
View raw message