// We make a copy of the message, then we strip out the unwanted routing id headers and leave
// only
// the one pertinent for the address node - this is important since different queues on different
// nodes could have same queue ids
// Note we must copy since same message may get routed to other nodes which require different headers
ServerMessage messageCopy = message.copy();
if (HornetQServerLogger.LOGGER.isTraceEnabled())
{
HornetQServerLogger.LOGGER.trace("Clustered bridge copied message " + message + " as " + messageCopy + " before delivery");
}
// TODO - we can optimise this
Set<SimpleString> propNames = new HashSet<SimpleString>(messageCopy.getPropertyNames());
byte[] queueIds = message.getBytesProperty(idsHeaderName);
if (queueIds == null)
{
// Sanity check only
HornetQServerLogger.LOGGER.noQueueIdDefined(message, messageCopy, idsHeaderName);
throw new IllegalStateException("no queueIDs defined");
}
for (SimpleString propName : propNames)
{
if (propName.startsWith(MessageImpl.HDR_ROUTE_TO_IDS))
{
messageCopy.removeProperty(propName);
}
}
messageCopy.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, queueIds);
messageCopy = super.beforeForward(messageCopy);
return messageCopy;
}