Stopping AMQP consumer on error #8672
-
Hi, Is there a way to cleanly stop an AMQP queue consumer on processing error? The best I've come up with is to close the listener container during the message's processing, from my tests it seems to achieve the required outcome (message remains in queue with no consumers), but as the container's stop() runs on the same thread the channel is being forcibly closed after the shutdown timeout and logs a warning. I can't find a place where I can hook up a consumer stop/cancel immediately after rejecting the message and before requesting a new one, is there a way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
We even have that recommendation in the docs: https://docs.spring.io/spring-amqp/reference/html/#event-consumption
|
Beta Was this translation helpful? Give feedback.
-
I'm already on 2.4.x, so I will pick that up (I'm assuming 2.9.10 is a typo). Indeed, I am using single action consumers on this particular case (with a prefetch of 1) and will also be enabling that. |
Beta Was this translation helpful? Give feedback.
-
Oops, you're right; investigating... |
Beta Was this translation helpful? Give feedback.
You can call the other
stop
variant and pass in a runnable, which will be called when the stop is complete (the container does the wait on another thread) - it currently works only for the SMLC; I am working on a fix for another problem that will enable it for the DMLC too; should be in a PR today.