{
return false;
}
});
ServerTransaction txn = new LocalTransaction(getVirtualHost().getTransactionLog());
if(_alternateExchange != null)
{
InboundMessageAdapter adapter = new InboundMessageAdapter();
for(final QueueEntry entry : entries)
{
adapter.setEntry(entry);
final List<? extends BaseQueue> rerouteQueues = _alternateExchange.route(adapter);
final ServerMessage message = entry.getMessage();
if(rerouteQueues != null && rerouteQueues.size() != 0)
{
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()
{
}
});
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();
if(_managedObject!=null)
{
_managedObject.unregister();