You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hengyunabc <he...@gmail.com> on 2013/06/07 04:09:39 UTC

Why the JMS MapMessage change after transfer through camel

Send:

Message message = session.createMapMessage();
message.setStringProperty("abc", "xyz");
producer.send(message);

Receive:
if(msg instanceof MapMessage){
    Enumeration<String> names = msg.getPropertyNames();
    while(names.hasMoreElements()){
	    String name = names.nextElement();
	    System.out.println("name:" + name + ", value:" +
msg.getObjectProperty(name));
    }
}

Output:
name:breadcrumbId, value:ID:mypc-47737-1370569760531-1:1:1:1:9
name:CamelJmsDeliveryMode, value:2
name:abc, value:xyz

The message content has changed!
How to get the original message content?



--
View this message in context: http://camel.465427.n5.nabble.com/Why-the-JMS-MapMessage-change-after-transfer-through-camel-tp5733975.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why the JMS MapMessage change after transfer through camel

Posted by hengyunabc <he...@gmail.com>.
I know why I was wrong.
The code should be:
Send:
MapMessage message = session.createMapMessage();
message.setString("abc", "xyz");

Receive:
Enumeration mapNames = mapMsg.getMapNames();
while(mapNames.hasMoreElements()){
  String name = (String) mapNames.nextElement();
  System.out.println("name:" + name + ", value:" + mapMsg.getObject(name));
}

Now everything is OK.
 



--
View this message in context: http://camel.465427.n5.nabble.com/Why-the-JMS-MapMessage-change-after-transfer-through-camel-tp5733975p5733976.html
Sent from the Camel - Users mailing list archive at Nabble.com.