Skip to content

Transactional channel is always closed after commit when using ThreadChannelConnectionFactory as publisher #1524

Closed

Description

@patrickfriedhoffpayone

Version
spring-rabbit:2.4.7

Description
I am using a ThreadChannelConnectionFactory within a RabbitTemplate with setChannelTransacted=true.
The rabbitTemplate.send is invoked within a transaction excuted with a TransactionTemplate.

When the transaction created by TransactionTemplate is committed, the corresponding RabbitMQ Channel is always closed.
The ThreadChannelConnection/RabbitTemplate is not used within a MessageListenerContainer.
I am expecting the ThreadChannelConnection to cache the channel and not to close it.

Code
The method:
ThreadChannelConnectionFactory.ConnectionWrapper.handleClose
if (transactional && this.txChannels.get() == null ? true : this.channels.get() == null) { physicalClose(channel); }

closes the channel.

In my opinion the if-statement seems not to be correct. In my case transactional is true, this.txChannels.get() is != null, but this.channels.get() is null. So
transactional && this.txChannels.get() == null is false, but
this.channels.get() == null is true and the channel is closed.

Shouldn´t it look like this?

transactional && this.txChannels.get() == null || !transactional && this.channels.get() == null

Activity

  1. self-assigned this
    on Oct 26, 2022
  2. added this to the 3.0.0 milestone on Oct 26, 2022
  3. added 2 commits that reference this issue on Oct 26, 2022
  4. added 2 commits that reference this issue on Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions