camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agentalpha <yogesh.l...@gmail.com>
Subject ActiveMQ InOut JMS messaging with external system
Date Thu, 16 Oct 2014 14:41:52 GMT
Hi Everyone,

I have a route where the final destination is:
activemq:queue:soapRequestQ?exchangePattern=InOut&asyncConsumer=true&useMessageIDAsCorrelationID=false&replyTo=responseQ&replyToType=Shared&requestTimeout=30000&transacted=false

In another route I have following configuration:
<route id="soapReqQToResQ">
		<from uri="activemq:queue:soapRequestQ"/>
		<process ref="headerProcessor"/>
		<process ref="openAPISimulator"/>
		
</route>

Using this configuration, the activemq inout messaging works perfectly fine
and I can achieve non blocking http request-response kind of behaviour using
this.

But when I try to do what second route is doing using a stand along activemq
java client, the inout message times out after configured time for not
getting any response. This is my java client part of code:
MessageConsumer consumer = session.createConsumer(request);// where request
is soapRequestQ
MessageProducer producer = session.createProducer(response);// where
response is responseQ

Message message = consumer.receive(1000);
if(message2 != null) {
				ActiveMQMapMessage activeMQMapMessage = (ActiveMQMapMessage) message;
				Map content = activeMQMapMessage.getContentMap();
				System.out.println("Received Message soapRequestQ: " + content);
				Map response = new HashMap();
				response.put("returnCode", "0");
				response.put("errorKey", "SUCCESS");
								
				try {
				// Convert Map to byte array
			    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
			    ObjectOutputStream out = new ObjectOutputStream(byteOut);
				out.writeObject(response);
				ByteSequence byteSequence = new ByteSequence(byteOut.toByteArray());
				ActiveMQMapMessage responseMapMessage = new ActiveMQMapMessage();
				responseMapMessage.setContent(byteSequence);
				responseMapMessage.setJMSDestination(response);
			
responseMapMessage.setJMSCorrelationID(activeMQMapMessage.getJMSCorrelationID());
			
responseMapMessage.setCorrelationId(activeMQMapMessage.getCorrelationId());
				
				producer.send(responseMapMessage);
				
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

I can see the message in responseQ. But it is not pickedup by camel for
InOut response.
Am I missing anything?
How the request-response in InOut pattern is connected? How does Camel auto
connects request and response in jms? I thought that JMSCorelationId was
enough for that. But it doesn't seems to be that way.
Please advice.
Thanks.

BR!
Yogesh



--
View this message in context: http://camel.465427.n5.nabble.com/ActiveMQ-InOut-JMS-messaging-with-external-system-tp5757630.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message