繁体   English   中英

在activemq消息中设置对象属性

[英]Set Object properties in activemq messages

如何在activemq消息中设置对象属性?

当我使用这种方法时,使用Apache Camel我什么也得不到!

在Activemq中:

        BytesMessage byteMessage = session.createBytesMessage();
        byteMessage.writeBytes(new byte[1]);
        byteMessage.setJMSReplyTo(tempDest);
        String correlationId = this.createRandomString();
        byteMessage.setJMSCorrelationID(correlationId);

        byteMessage.setStringProperty("param1", "x");

        HashMap<String, String> map = new HashMap<String, String>();
        map.put("param3", "y");
        map.put("param4", "z");
        byteMessage.setObjectProperty("param2", map);

然后在骆驼:

....
    .process(new Processor() {
        public void process(Exchange exchange) throws Exception {
            Message in = exchange.getIn();
            System.out.println(in.getHeaders().keySet());

            Object map= in.getHeaders().get("param2");
            System.out.println(map);
            }
        })
    ;

在keySet()中没有param2! 并且最后一行的结果是NULL!

Map不是setObjectProperty的有效对象。 来自Javadoc for Message:

“属性值可以是boolean,byte,short,int,long,float,double和String。”

http://docs.oracle.com/javaee/1.4/api/javax/jms/Message.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM