spring-amqp
spring-amqp copied to clipboard
RabbitTemplate with SIMPLE correlation causes uncached channels
Discussed in https://github.com/spring-projects/spring-amqp/discussions/2571
Originally posted by bjoernhaeuser December 15, 2023 Hello everyone,
I hope this discussion is at the right place.
We are using a CachingConnectionFactory with CachingConnectionFactory.ConfirmType.SIMPLE
as publisher confirm type setting.
Then we are using the RabbitTemplate something like this:
this.amqpTemplate.invoke(operations -> {
// send messages
// operations.waitForConfirmsOrDie(10_000);
}
I thought this reuses channels, but after looking at the RabbitMQ stats I see a relatively high channel churn (in our case 50-100 channels/sec) and digging into this it looks like the RabbitTemplate is creating a new channel for every .invoke()
call.
After a debugging session through the code I saw that the RabbitTemplate::invoke
method calls RabbitUtils.setPhysicalCloseRequired(channel, true);
Reference, when the connectionFactory says that publisher confirms are deactivated.
Right now the connectionFactory.isPublisherConfirms()
would only return true when the ConfirmType
is set to CORRELATED
Reference.
I am not familiar enough to judge if this is the right condition, but it looks to be that it should be changed to say return !ConfirmType.NONE.equals(this.confirmType)
.
Changing the value to be of confirmType CORRELATED
changes the behaviour and channels are properly cached. Can someone please advise if my findings are correct and/or if I am using it simply wrong?
Thank you very much!