When running a listener container with local transactions (channelTransacted, and no external transaction manager), the consumer's channel is bound to the thread for use by downstream RabbitTemplates. However, the syncronizedWithTransaction boolean was not set so the RabbitTemplate closed the channel after its operation. We should never close the consumer's channel. The solution is to set the boolean when binding the resource. In addition, when using a RabbitTransactionManager, the RabbitResourceHolder.closeAll() method would close the consumer's channel. Previously, the consumer's channel was registered with a ThreadLocal in the ConnectionFactoryUtils. This enabled the doGetTransactionalResourceHolder method to bind the consumer's channel. The RabbitResourceHolder.closeAll() now examines the channels is it closing and skips the close for the consumer's channel. Added tests to the Local and External transaction test cases to ensure the appropriate channel.close() calls are executed, depending on the scenario. e.g. a local transaction with exposeListenerChannel=false should close() the exposed channel but not the consumer's channel.
Many of the "integration" tests here require a running RabbitMQ server - they will be skipped if the broker is not detected.
If RabbitMQ is not installed on your system, refer to the instructions for your particular OS here: [http://www.rabbitmq.com/install.html]
Start the server. For example, and a *nix-based system where RabbitMQ has been
installed within /opt/rabbitmq, issue the following command:
> sudo /opt/rabbitmq/sbin/rabbitmq-server start