I tried to log response code by adding a bean class to my flow
from("jmstx:queue:spq2").bean(myBean,"setLocationUrI")
.recipientList(header(HttpProducer.HTTP_URI)).bean(myBean,"printResponse");
in the printResponse() method I have below code
log.info("MyBeanProcessor - Calling printResponse");
log.info("MyBeanProcessor -exchange.isFailed():" +
exchange.isFailed());
Message out = exchange.getOut(); // giving nullpointerexception
Object val = out.getHeader(HttpProducer.HTTP_RESPONSE_CODE);
if (val != null) {
log.info("MyBeanProcessor -val NOT null");
} else {
log.info("MyBeanProcessor -val null");
}
it is printing "val null"
How would I recieve the resaponse code from http call? Do I need create an
interceptor code? Please suggest. Any sample will be very helpful
gnanda wrote:
>
> Thanks for the reply. In my scenario, the call to http is a an async call
> where the external webservice does not return any reply back. But it would
> just return me the status code whether accepted or not (200). I think I
> need to write an interceptor code for this, but not sure how to write it
> Any sample code or document will be very helpful
>
>
> Claus Ibsen-2 wrote:
>>
>> On Fri, Apr 23, 2010 at 8:45 PM, gnanda
>> <[email protected]> wrote:
>>>
>>> Hi all,
>>> I am using camel to read a message from a Q sending to a HTTP
>>> my route is as below
>>> from("jmstx:queue:spq2").bean(myBean,"setLocationUrI")
>>> .recipientList(header(HttpProducer.HTTP_URI));
>>>
>>> I need to recive response code from the above http URI.
>>> I need to make sure I receive 200 or 202 to declare as a success call.
>>> How
>>> would I receive the response code ?
>>> Do I need to make the mep as in-out while sending exchange to external
>>> web
>>> service thru http endpoint to get the return code?
>>>
>>
>> Since you only send to 1 endpoint in RecipientList, then Camel will
>> return the last exchange as reply.
>>
>> So simply just continue routing after the recipient list, where you
>> can check for the 200/202 codes.
>>
>> If you send to multiple endpoints in recipient list you can use an
>> AggregationStrategy to merge the results together.
>>
>>
>>> Please suggest
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/smx%3Acamel%3A-receiving-http-response-tp28345025p28345025.html
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
>
--
View this message in context:
http://old.nabble.com/smx%3Acamel%3A-receiving-http-response-tp28345025p28367318.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.