You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Usha13 <us...@yahoo.com> on 2013/07/25 00:52:42 UTC
Different response messages
Hello,
I am using an InOut queue and configured the following route on that queue:
from("activemq:queue:numbers").unmarshal(mapFormat)
.choice()
.when(simple("${in.body['EventType']} == 'Event1'"))
.convertBodyTo(String.class)
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.enrich("http://service1", aggrStrategy)
.when(simple("${in.body['EventType']} == 'Event2'"))
.beanRef("multiplier", "multiply")
.otherwise()
.beanRef("multiplier", "multiply")
;
I have implemented content enricher pattern here and the aggrStrategy will
retrieve a parameter from the response of service1, add it to the original
request and send that new response.
The first time I run this code it works fine and gives me the new response.
Then next time I run it, the response I get is the response directly from
service1. The aggregation strategy code is not applied and it just returns
the complete response from service1. I get this response for any event type
(EventType1, EventType2 etc).
This happens in an alternate fashion. Meaning every second run I get the
wrong response.
I am using activemq component and activemq is running on my local machine.
Am I missing some configuration or some piece of code here?
Thank you
Usha
--
View this message in context: http://camel.465427.n5.nabble.com/Different-response-messages-tp5736239.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Different response messages
Posted by Usha13 <us...@yahoo.com>.
I am using simple Java to post messages. Heres the code:
//Reading the camel config from the spring config file
ApplicationContext context = new
ClassPathXmlApplicationContext("camel-client.xml");
CamelContext camel = context.getBean("camel-client",
CamelContext.class);
Endpoint endpoint = camel.getEndpoint("activemq:queue:numbers");
Exchange exchange = endpoint.createExchange(ExchangePattern.InOut);
// set the input on the in body
String request = "{MessageId:A0FA0DC53957743EE040100A0E540E97,
EventType:Event1} ";
exchange.getIn().setBody(request);
// to send the exchange we need an producer to do it for us
Producer producer = endpoint.createProducer();
// start the producer so it can operate
producer.start();
// let the producer process the exchange where it does all the work
in this oneline of code
producer.process(exchange);
// get the response from the out body
String response = exchange.getOut().getBody(String.class);
I have been sending only Event1 to the queue
--
View this message in context: http://camel.465427.n5.nabble.com/Different-response-messages-tp5736239p5736302.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Different response messages
Posted by Willem jiang <wi...@gmail.com>.
How did you feed the message to activemq?
Have you been always sending the Event1 to the queue?
--
Willem Jiang
Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem
On Thursday, July 25, 2013 at 6:52 AM, Usha13 wrote:
> Hello,
>
> I am using an InOut queue and configured the following route on that queue:
> from("activemq:queue:numbers").unmarshal(mapFormat)
> .choice()
> .when(simple("${in.body['EventType']} == 'Event1'"))
>
> .convertBodyTo(String.class)
> .setHeader(Exchange.HTTP_METHOD, constant("GET"))
> .enrich("http://service1", aggrStrategy)
> .when(simple("${in.body['EventType']} == 'Event2'"))
> .beanRef("multiplier", "multiply")
>
> .otherwise()
> .beanRef("multiplier", "multiply")
> ;
>
> I have implemented content enricher pattern here and the aggrStrategy will
> retrieve a parameter from the response of service1, add it to the original
> request and send that new response.
>
> The first time I run this code it works fine and gives me the new response.
> Then next time I run it, the response I get is the response directly from
> service1. The aggregation strategy code is not applied and it just returns
> the complete response from service1. I get this response for any event type
> (EventType1, EventType2 etc).
> This happens in an alternate fashion. Meaning every second run I get the
> wrong response.
>
> I am using activemq component and activemq is running on my local machine.
>
> Am I missing some configuration or some piece of code here?
>
> Thank you
> Usha
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Different-response-messages-tp5736239.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).