}
else
{
if (context.getTransaction() == null)
{
context.setTransaction(new TransactionImpl(storageManager));
startedTX.set(true);
}
}
cacheBridge.addToCache(bridgeDupBytes, context.getTransaction());
message.removeProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID);
}
else
{
// if used BridgeDuplicate, it's not going to use the regular duplicate
// since this will would break redistribution (re-setting the duplicateId)
byte[] duplicateIDBytes = message.getDuplicateIDBytes();
DuplicateIDCache cache = null;
boolean isDuplicate = false;
if (duplicateIDBytes != null)
{
cache = getDuplicateIDCache(message.getAddress());
isDuplicate = cache.contains(duplicateIDBytes);
if (rejectDuplicates && isDuplicate)
{
HornetQServerLogger.LOGGER.duplicateMessageDetected(message);
String warnMessage = "Duplicate message detected - message will not be routed. Message information:" + message.toString();
if (context.getTransaction() != null)
{
context.getTransaction().markAsRollbackOnly(new HornetQDuplicateIdException(warnMessage));
}
message.decrementRefCount();
return false;
}
}
if (cache != null && !isDuplicate)
{
if (context.getTransaction() == null)
{
// We need to store the duplicate id atomically with the message storage, so we need to create a tx for this
context.setTransaction(new TransactionImpl(storageManager));
startedTX.set(true);
}
cache.addToCache(duplicateIDBytes, context.getTransaction());