【问题标题】:HornetQ JMSXGroupID property clobbered to _HQ_GROUP_ID using wildfly 8使用 Wildfly 8 将 HornetQ JMSXGroupID 属性更改为 _HQ_GROUP_ID
【发布时间】:2015-03-14 08:29:16
【问题描述】:

是否可以在 HornetQ 中更改 _HQ_GROUP_ID 名称值?我正在使用 Wildfly 8 和默认的 HornetQ JMS 系统。我已经配置了一个网桥来将本地大黄蜂队列连接到远程 ActiceMQ 队列。当发送带有 JMSXGroupID 属性集的消息时,HornetQ 似乎将名称更改为 _HQ_GROUP_ID。为什么会这样,有什么办法可以改变吗?

相关代码,

try {
    message.clearProperties();
    MapMessage map = (MapMessage) message;

    String customer = map.getString("customer");
    String location = map.getString("location");

    // setting the property here
    message.setStringProperty("JMSXGroupID", customer + "@" + location);

    message.setJMSTimestamp(System.currentTimeMillis());
    context.createProducer().send(msmt, message); // relay message to apacheMQ in chaos

} catch (JMSException jmse) {
    log.severe(jmse.getMessage());
}

【问题讨论】:

    标签: jboss jms activemq hornetq wildfly-8


    【解决方案1】:

    似乎在调用 setStringProperty() 时会检查 HornetQ 源代码中的“JMSXGroupID”,然后用 _HQ_GROUP_ID 覆盖 HornetQ 的内部分组表示,

    public void setStringProperty(final String name, final String value) throws JMSException
       {
          checkProperty(name);
    
          if (HornetQMessage.JMSXGROUPID.equals(name))
          {
             message.putStringProperty(org.hornetq.api.core.Message.HDR_GROUP_ID, SimpleString.toSimpleString(value));
          }
          else
          {
             message.putStringProperty(new SimpleString(name),  SimpleString.toSimpleString(value));
          }
       }
    

    因此,解决方法是改用 setObjectProperty(String,Object) 方法。

    try {
                message.clearProperties();
                MapMessage map = (MapMessage) message;
    
                String customer = map.getString("customer");
                String location = map.getString("location");
    
                message.setObjectProperty("JMSXGroupID", customer + "@" + location);
                //message.setStringProperty("JMSXGroupID", customer + "@" + location);
    
                message.setJMSTimestamp(System.currentTimeMillis());
                context.createProducer().send(msmt, message); // relay message to apacheMQ in chaos
    
            } catch (JMSException jmse) {
                log.severe(jmse.getMessage());
            }
        }
    

    这并不明显,可能只是临时解决方法。 HornetQ 依靠这种表示来进行自己的分组和集群,因此除非您有一个正确的桥接器连接到理解这种表示的 JMS 代理(例如 ActiveMQ),否则这可能会造成很大的损害。

    【讨论】:

      猜你喜欢
      • 2015-04-14
      • 2014-07-29
      • 1970-01-01
      • 2017-10-15
      • 2020-06-10
      • 2013-01-14
      • 2020-04-28
      • 2021-11-19
      • 2017-01-08
      相关资源
      最近更新 更多