{
final AMQQueue queue = _virtualHost.getQueueRegistry().getQueue(record.getQueue().getResourceName());
if(queue != null)
{
final long messageId = record.getMessage().getMessageNumber();
final AbstractServerMessageImpl message = _recoveredMessages.get(messageId);
_unusedMessages.remove(messageId);
if(message != null)
{
message.incrementReference();
branch.enqueue(queue,message);
branch.addPostTransactionAcion(new ServerTransaction.Action()
{
public void postCommit()
{
try
{
queue.enqueue(message, true, null);
message.decrementReference();
}
catch (AMQException e)
{
_logger.error("Unable to enqueue message " + message.getMessageNumber() + " into " +
"queue " + queue.getName() + " (from XA transaction)", e);
throw new RuntimeException(e);
}
}
public void onRollback()
{
message.decrementReference();
}
});
}
else
{
StringBuilder xidString = xidAsString(id);
String messageNumberString = String.valueOf(message.getMessageNumber());
CurrentActor.get().message(_logSubject,
TransactionLogMessages.XA_INCOMPLETE_MESSAGE(xidString.toString(),
messageNumberString));
}
}
else
{
StringBuilder xidString = xidAsString(id);
CurrentActor.get().message(_logSubject,
TransactionLogMessages.XA_INCOMPLETE_QUEUE(xidString.toString(),
record.getQueue().getResourceName()));
}
}
for(MessageStore.Transaction.Record record : dequeues)
{
final AMQQueue queue = _virtualHost.getQueueRegistry().getQueue(record.getQueue().getResourceName());
if(queue != null)
{
final long messageId = record.getMessage().getMessageNumber();
final AbstractServerMessageImpl message = _recoveredMessages.get(messageId);
_unusedMessages.remove(messageId);
if(message != null)
{
final QueueEntry entry = queue.getMessageOnTheQueue(messageId);
entry.acquire();
branch.dequeue(queue, message);
branch.addPostTransactionAcion(new ServerTransaction.Action()
{
public void postCommit()
{
entry.discard();
}
public void onRollback()
{
entry.release();
}
});
}
else
{
StringBuilder xidString = xidAsString(id);
String messageNumberString = String.valueOf(message.getMessageNumber());
CurrentActor.get().message(_logSubject,
TransactionLogMessages.XA_INCOMPLETE_MESSAGE(xidString.toString(),
messageNumberString));
}