-
Notifications
You must be signed in to change notification settings - Fork 646
Closed
Milestone
Description
In what version(s) of Spring AMQP are you seeing this issue?
3.2.8
Describe the bug
When having an async Rabbit listener which throws an exception and the error handler returns null (assuming that the exception had been somehow mitigated (e.g. triggering a retry), the message is not acked but 'hangs' unacked for all eternity (or until the rabbit server times out).
In contrast using the same logic with a sync listener, the message is acked.
To Reproduce
Send a message to an the queue theQueue and the message stays anacked. Send a message to theOtherQueue and the message is consumed.
@Component
class Consumer() {
@RabbitListener(queues = ["theQueue"], errorHandler = "errorHandler" )
suspend fun consumeRabbitMessage(message: Message): Unit? {
throw RuntimeException("something went wrong while consuming the message")
}
@RabbitListener(queues = ["theOtherQueue"], errorHandler = "errorHandler" )
fun consumeRabbitMessageSync(message: Message): Unit? {
throw RuntimeException("something went wrong while consuming the message")
}
}
@Component
class ErrorHandler : RabbitListenerErrorHandler {
override fun handleError(
msg: Message?,
ch: Channel?,
msg2: org.springframework.messaging.Message<*>?,
ex: ListenerExecutionFailedException?
): Any? {
//asume the error was handled internally
return null
}
}
Expected behavior
The message should be acked (analog behaviour to a sync listener)