Is is possible to change the _HQ_GROUP_ID name value in HornetQ? I am using Wildfly 8 and the default HornetQ JMS system. I have configured a bridge to interface a local hornet queue to a remote ActiceMQ queue. When sending a message with JMSXGroupID property set HornetQ seems to clober the name to _HQ_GROUP_ID. Why does it do this and is there any way to change it?
是否可以在HornetQ中更改_HQ_GROUP_ID名值?我正在使用Wildfly 8和默认的HornetQ JMS系统。我已经配置了一个连接本地大黄蜂队列到远程ActiceMQ队列的桥。当使用JMSXGroupID属性设置发送消息时,HornetQ似乎将名称截断为_HQ_GROUP_ID。为什么会这样,有没有办法改变它?
Relevant code,
相关的代码,
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());
}
1 个解决方案
#1
0
Seems that in the HornetQ source code "JMSXGroupID" is checked when setStringProperty() is called and then overwritten with _HQ_GROUP_ID for the internal grouping representation of HornetQ,
似乎在HornetQ源代码“JMSXGroupID”中,调用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));
}
}
So a workaround for this is to use the setObjectProperty(String,Object) method instead.
解决这个问题的方法是使用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());
}
}
This is not obvious and may only be a temporary workaround. HornetQ relies on this representation for its own grouping and clustering so unless you have a correct bridge to a JMS broker that understands this representation (such as ActiveMQ) then this has the potential to do a lot of damage.
这并不明显,可能只是暂时的解决办法。HornetQ依赖这种表示来进行自己的分组和集群,因此除非您有一个正确的桥接到一个理解这种表示的JMS代理(例如ActiveMQ),否则这可能会造成很大的损害。
#1
0
Seems that in the HornetQ source code "JMSXGroupID" is checked when setStringProperty() is called and then overwritten with _HQ_GROUP_ID for the internal grouping representation of HornetQ,
似乎在HornetQ源代码“JMSXGroupID”中,调用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));
}
}
So a workaround for this is to use the setObjectProperty(String,Object) method instead.
解决这个问题的方法是使用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());
}
}
This is not obvious and may only be a temporary workaround. HornetQ relies on this representation for its own grouping and clustering so unless you have a correct bridge to a JMS broker that understands this representation (such as ActiveMQ) then this has the potential to do a lot of damage.
这并不明显,可能只是暂时的解决办法。HornetQ依赖这种表示来进行自己的分组和集群,因此除非您有一个正确的桥接到一个理解这种表示的JMS代理(例如ActiveMQ),否则这可能会造成很大的损害。