Jun 4th, 2012, 09:23 AM
Transacted channel not being returned to cache after send
I'm sending a message with RabitTemplate in a transacted channel using an external platform transaction manager (In this case the JPA one). After the transaction commits/rollsback I would expect its channel to be returned to the cache lists in CachingConnectionFactory, but it does not. This makes each send open a new channel which never gets reused. This can be seen in the rabbit server management tool.
There is code in org.springframework.amqp.rabbit.connection.Connect ionFactoryUtils.RabbitResourceSynchronization to achieve this release but it does not work as it calls through to org.springframework.amqp.rabbit.connection.Connect ionFactoryUtils.releaseResources(RabbitResourceHol der resourceHolder) and this checks resourceHolder.isSynchronizedWithTransaction() which is true so the method returns and the channel/connection are not released.
A quick fix would be to set the resource holder as not synchronisedWithTransaction in org.springframework.amqp.rabbit.connection.Connect ionFactoryUtils.RabbitResourceSynchronization.afte rCompletion(int status) there is a commented out line of code to do exactly that, which is strange.
This seems to be the same issue described in https://jira.springsource.org/browse/AMQP-190 which is marked as resolved, but there is no information about the actual fix.
This is present in 1.1.0 and 1.1.1.