You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by satyanarayana <sa...@gmail.com> on 2014/07/03 16:03:15 UTC

Exchange messagecontainer is getting changed during the process

Hi All,

My requirement flow: Asynchronous flow

 a)gets the request  through web service
 b)will push the  request into  queue(activeMQ)
 c) will fetch the message from request queue, send to the external system
 d) external system will take sometime to process and reply back
 e) we have listener , listening to external system
 f) the listener captures the response and pushing into response queue
 g) external system has provided API (external system jars) for
communication from our system
 
 After fetching message from response queue, what i found is the exchange
message container is changed since exchange id is different. hence the
header properties what i set initially are missing and my security
interceptors is throwing exception and unable to proceed.

below is the code what  i am using while pushing the message into
responsequeue

import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import javax.jms.BytesMessage;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.Session;

public void sendJMSMessage(final String msgType,final Serializable
msgObject) throws Exception {
               
                jmsTemplate.setDefaultDestination(responseQueue);
               
jmsTemplate.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
                jmsTemplate.send(new MessageCreator() {
                        public Message createMessage(Session session)
                                        throws JMSException {
                                Message message = null;
                                if (msgType.equals("String")) {
                                        message =
session.createTextMessage(msgObject
                                                        .toString());
                                } else if (msgType.equals("Object")) {
                                        message =
session.createObjectMessage(msgObject);
                                        LOGGER.info("Object message is
created");
                                } else if (msgType.equals("Bytes")) {
                                        byte[] bytes =
msgObject.toString().getBytes();
                                        BytesMessage byteMessage =
session.createBytesMessage();
                                        byteMessage.writeBytes(bytes);
                                        message = byteMessage;
                                } else {
                                        LOGGER.info("ERROR Invalid message
type:" + msgType);
                                }
                                return message;
                        }
                });
}

Can you please let me know the solution for the above issue. 



--
View this message in context: http://camel.465427.n5.nabble.com/Exchange-messagecontainer-is-getting-changed-during-the-process-tp5753289.html
Sent from the Camel - Users mailing list archive at Nabble.com.