SpringSource/spring-amqp — pull request #57 by garyrussell (2012-07-13 23:55:13+00:00)
Title: AMQP-190 Memory Leak With Tx and RabbitTemplate

When the RabbitTemplate is invoked with an existing transaction,
the channel is bound to the thread, and

ConnectionFactoryUtils.releaseResources(resourceHolder);

is called after processing. There was a commented-out line
in ConnectionFactoryUtils.RabbitResourceSynchronization.afterCompletion()
that would have reset the synchronized state so that
releaseResouces() would "close" the chanel/connection (return
them to the caching factory).

Being commented out, the channel was never removed, and each
transactional template call grabbed a new channel.

However, uncommenting causes issues with the listener container
because it continues to use the channel, so it must not
be closed (made available for reuse).

Added code to reset synch, by default, but not for the listener.

The listener sets a boolean releaseAfterCompletion in the
ResourceHolder to false so that the channel remains and
is not closed (logically or otherwise).