{
return false;
}
});
ServerTransaction txn = new LocalTransaction(getVirtualHost().getMessageStore());
if(_alternateExchange != null)
{
InboundMessageAdapter adapter = new InboundMessageAdapter();
for(final QueueEntry entry : entries)
{
adapter.setEntry(entry);
List<? extends BaseQueue> queues = _alternateExchange.route(adapter);
if((queues == null || queues.size() == 0) && _alternateExchange.getAlternateExchange() != null)
{
queues = _alternateExchange.getAlternateExchange().route(adapter);
}
final ServerMessage message = entry.getMessage();
if(queues != null && queues.size() != 0)
{
final List<? extends BaseQueue> rerouteQueues = queues;
txn.enqueue(rerouteQueues, entry.getMessage(),
new ServerTransaction.Action()
{
public void postCommit()
{
try
{
for(BaseQueue queue : rerouteQueues)
{
queue.enqueue(message);
}
}
catch (AMQException e)
{
throw new RuntimeException(e);
}
}
public void onRollback()
{
}
}, 0L);
txn.dequeue(this, entry.getMessage(),
new ServerTransaction.Action()
{
public void postCommit()
{
entry.discard();
}
public void onRollback()
{
}
});
}
}
_alternateExchange.removeReference(this);
}
else
{
// TODO log discard
for(final QueueEntry entry : entries)
{
final ServerMessage message = entry.getMessage();
if(message != null)
{
txn.dequeue(this, message,
new ServerTransaction.Action()
{
public void postCommit()
{
entry.discard();
}
public void onRollback()
{
}
});
}
}
}
txn.commit();
for (Task task : _deleteTaskList)
{
task.doTask(this);
}