{
final AMQProtocolSession session = stateManager.getProtocolSession();
try
{
AMQChannel channel = session.getChannel(channelId);
if (channel == null)
{
throw body.getChannelNotFoundException(channelId);
}
final MethodRegistry methodRegistry = session.getMethodRegistry();
final AMQMethodBody responseBody = methodRegistry.createTxRollbackOkBody();
Runnable task = new Runnable()
{
public void run()
{
session.writeFrame(responseBody.generateFrame(channelId));
}
};
channel.rollback(task);
//Now resend all the unacknowledged messages back to the original subscribers.
//(Must be done after the TxnRollback-ok response).
// Why, are we not allowed to send messages back to client before the ok method?
channel.resend(false);
}
catch (AMQException e)
{
throw body.getChannelException(e.getErrorCode(), "Failed to rollback: " + e.getMessage());