Skip to content

Prevent high channel churn in a queue full scenario#9181

Merged
oscerd merged 2 commits intoapache:camel-3.20.xfrom
groundhog2k:patch-1
Jan 24, 2023
Merged

Prevent high channel churn in a queue full scenario#9181
oscerd merged 2 commits intoapache:camel-3.20.xfrom
groundhog2k:patch-1

Conversation

@groundhog2k
Copy link
Copy Markdown

@groundhog2k groundhog2k commented Jan 20, 2023

In a scenario with a high message publishing rate and a full queue the publisher will get "nack" (not acknowledged) as feedback from RabbitMQ.

The method Channel#waitForConfirmsOrDie(long) in https://github.com/rabbitmq/rabbitmq-java-client/blob/main/src/main/java/com/rabbitmq/client/impl/ChannelN.java#L241 will close the channel. This closed channel is then given back to the channel pool. Next time the channel is taken out of the pool it is detected as closed and will be removed. So a new channel needs to be opened and this too will be closed directly after usage when the same queue is still full. There will be a high rate of opened and closed communication channels and the channel pool gets unusable.

This is described as high channel churn (https://www.rabbitmq.com/channels.html#high-channel-churn) and can have side effects on RabbitMQ (memory and cpu resource usage) and performance too.

It was also discussed with folks from rabbitmq-java-client (rabbitmq/rabbitmq-java-client#942) and the usage of Channel#waitForConfirmsOrDie(long) is "highly NOT recommended" by them.

This behavior affects ALL versions of the camel-rabbitmq component!

In a scenario with a high message publishing rate and a full queue the publisher will get "nack" (not acknowledged) as feedback from RabbitMQ. 

The method Channel#waitForConfirmsOrDie(long) in https://github.com/rabbitmq/rabbitmq-java-client/blob/main/src/main/java/com/rabbitmq/client/impl/ChannelN.java#L241 will close the channel. This closed channel is then given back to the channel pool. 
Next time the channel is taken out of the pool it is detected as closed and will be removed. So a new channel needs to be opened and this too will be closed directly after usage when the same queue is still full. There will be a high rate of opened and closed communication channels and the channel pool gets unusable. 

This is described as high channel churn (https://www.rabbitmq.com/channels.html#high-channel-churn) and can have side effects on RabbitMQ (memory and cpu resource usage) and performance too.

It was also discussed with folks from rabbitmq-java-client (rabbitmq/rabbitmq-java-client#942) and the usage of Channel#waitForConfirmsOrDie(long) is "highly NOT recommended" by them.

This behavior affects ALL versions of the camel-rabbitmq component!
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟

⚠️ Please note that the changes on this PR may be tested automatically.

If necessary Apache Camel Committers may access logs and test results in the job summaries!

Copy link
Copy Markdown
Contributor

@oscerd oscerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this.

This should go also on camel-3.x. This component is deprecated and it has been removed in camel 4.x, in favor of camel-spring-rabbitmq.

Please open a PR again camel-3.x too.

@groundhog2k groundhog2k changed the base branch from camel-3.20.x to camel-3.x January 20, 2023 13:47
@groundhog2k groundhog2k changed the base branch from camel-3.x to camel-3.20.x January 20, 2023 13:48
@groundhog2k groundhog2k deleted the patch-1 branch January 20, 2023 13:52
@oscerd
Copy link
Copy Markdown
Contributor

oscerd commented Jan 20, 2023

Please don't close this one, this is a bug, so it should go on 3.20.x too, thanks.

@groundhog2k groundhog2k restored the patch-1 branch January 20, 2023 15:12
@groundhog2k groundhog2k reopened this Jan 20, 2023
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟

⚠️ Please note that the changes on this PR may be tested automatically.

If necessary Apache Camel Committers may access logs and test results in the job summaries!

@oscerd oscerd merged commit 38ade3c into apache:camel-3.20.x Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants