Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
patrickfriedhoffpayone opened this issue Oct 26, 2022 · 0 comments · Fixed by #1525

Comments

@patrickfriedhoffpayone
Copy link

patrickfriedhoffpayone commented Oct 26, 2022

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

@garyrussell garyrussell self-assigned this Oct 26, 2022
@garyrussell garyrussell added this to the 3.0.0 milestone Oct 26, 2022
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Oct 26, 2022
Resolves spring-projects#1524

Channel was always physically closed.

**cherry-pick to 2.4.x**
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Oct 26, 2022
Resolves spring-projects#1524

Channel was always physically closed.

**cherry-pick to 2.4.x**
artembilan pushed a commit that referenced this issue Oct 26, 2022
Resolves #1524

Channel was always physically closed.

**cherry-pick to 2.4.x**
artembilan pushed a commit that referenced this issue Oct 26, 2022
Resolves #1524

Channel was always physically closed.

**cherry-pick to 2.4.x**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants