Jboss 使用wildfly 8将HornetQ JMSXGroupID属性克隆到_HQ_GROUP_ID
是否可以更改HornetQ中的_HQ_GROUP_ID name值?我使用的是Wildfly 8和默认的HornetQ JMS系统。我已经配置了一个网桥,将本地hornet队列连接到远程ActiveMQ队列。当发送带有JMSXGroupID属性集的消息时,HornetQ似乎将名称克隆到了_HQ_GROUP_ID。它为什么会这样做?有没有办法更改它 相关规范Jboss 使用wildfly 8将HornetQ JMSXGroupID属性克隆到_HQ_GROUP_ID,jboss,jms,activemq,hornetq,wildfly-8,Jboss,Jms,Activemq,Hornetq,Wildfly 8,是否可以更改HornetQ中的_HQ_GROUP_ID name值?我使用的是Wildfly 8和默认的HornetQ JMS系统。我已经配置了一个网桥,将本地hornet队列连接到远程ActiveMQ队列。当发送带有JMSXGroupID属性集的消息时,HornetQ似乎将名称克隆到了_HQ_GROUP_ID。它为什么会这样做?有没有办法更改它 相关规范 try { message.clearProperties(); MapMessage map = (MapMessage)
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());
}
似乎在HornetQ源代码中,当调用setStringProperty时会检查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));
}
}
因此,解决方法是使用setObjectPropertyString,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,否则这可能会造成很大的损害