}
}
public boolean checkRedelivery(final MessageReference reference, final long timeBase, final boolean ignoreRedeliveryDelay) throws Exception
{
ServerMessage message = reference.getMessage();
if (internalQueue)
{
if (isTrace)
{
HornetQServerLogger.LOGGER.trace("Queue " + this.getName() + " is an internal queue, no checkRedelivery");
}
// no DLQ check on internal queues
return true;
}
if (!internalQueue && message.isDurable() && durable && !reference.isPaged())
{
storageManager.updateDeliveryCount(reference);
}
AddressSettings addressSettings = addressSettingsRepository.getMatch(address.toString());
int maxDeliveries = addressSettings.getMaxDeliveryAttempts();
long redeliveryDelay = addressSettings.getRedeliveryDelay();
int deliveryCount = reference.getDeliveryCount();
// First check DLA
if (maxDeliveries > 0 && deliveryCount >= maxDeliveries)
{
if (isTrace)
{
HornetQServerLogger.LOGGER.trace("Sending reference " + reference + " to DLA = " + addressSettings.getDeadLetterAddress() + " since ref.getDeliveryCount=" + reference.getDeliveryCount() + "and maxDeliveries=" + maxDeliveries + " from queue=" + this.getName());
}
sendToDeadLetterAddress(reference, addressSettings.getDeadLetterAddress());
return false;
}
else
{
// Second check Redelivery Delay
if (!ignoreRedeliveryDelay && redeliveryDelay > 0)
{
redeliveryDelay = calculateRedeliveryDelay(addressSettings, deliveryCount);
if (isTrace)
{
HornetQServerLogger.LOGGER.trace("Setting redeliveryDelay=" + redeliveryDelay + " on reference=" + reference);
}
reference.setScheduledDeliveryTime(timeBase + redeliveryDelay);
if (!reference.isPaged() && message.isDurable() && durable)
{
storageManager.updateScheduledDeliveryTime(reference);
}
}