【问题标题】:Set Object properties in activemq messages在 activemq 消息中设置对象属性
【发布时间】:2013-12-01 15:30:22
【问题描述】:

如何在 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!

【问题讨论】:

    标签: java jms activemq apache-camel


    【解决方案1】:

    地图不是 setObjectProperty 的有效对象。来自消息的 Javadoc:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-06
      • 2014-05-02
      • 2018-10-31
      • 2017-10-23
      • 2014-06-27
      • 2013-08-10
      • 2018-05-21
      • 1970-01-01
      相关资源
      最近更新 更多