0

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?

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 Answers1

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,

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.

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.