You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In what version(s) of Spring AMQP are you seeing this issue?
3.1.5
Describe the bug
When use Kotlin suspend (or reactive) RabbitListener with consumerBatch and AcknowledgeMode.MANUAL error occurs
Operator called default onErrorDropped java.lang.NullPointerException: Cannot invoke \"org.springframework.amqp.core.Message.getMessageProperties()\" because \"request\" is null\n\tat org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener.basicAck(AbstractAdaptableMessageListener.java:444)
To Reproduce
Below fragments using Kotlin
Configure SimpleRabbitListenerContainerFactory with settings:
val factory =SimpleRabbitListenerContainerFactory()
// ...
factory.setConsumerBatchEnabled(true)
factory.setDeBatchingEnabled(true)
factory.setBatchSize(100)
factory.setPrefetchCount(100)
factory.setAcknowledgeMode(AcknowledgeMode.MANUAL)
Define rabbit listener like this:
@RabbitListener(queues = ["some-queue"], )
suspendfunreceiveSensorMessage(messages:List<String>): Unit {
service.handleMessages(messages)
}
And after recieve messages and handled its you will get an error:
Operator called default onErrorDropped java.lang.NullPointerException: Cannot invoke \"org.springframework.amqp.core.Message.getMessageProperties()\" because \"request\" is null\n\tat org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener.basicAck(AbstractAdaptableMessageListener.java:444)
After some research source code of spring-amqp I have explanation why it is happens:
It is invokes invokeHandlerAndProcessResult method with amqpMessage = null and after invokeHandler we get result as MonoOnAssembly therefore we also call handleResult method where we basicAck will be called with request as null (because above we pass it as amqpMessage = null).
Expected behavior
No error occurs while using suspend RabbitListener with consumerBatch and AcknowledgeMode.MANUAL
The text was updated successfully, but these errors were encountered:
Have just pushed the fix for the next version.
I don't consider it to be back-ported since technically we never advertised that batch mode would work with async returns.
Anyway thank you for the detailed report!
In what version(s) of Spring AMQP are you seeing this issue?
3.1.5
Describe the bug
When use Kotlin suspend (or reactive)
RabbitListener
withconsumerBatch
andAcknowledgeMode.MANUAL
error occursTo Reproduce
Below fragments using Kotlin
Configure
SimpleRabbitListenerContainerFactory
with settings:Define rabbit listener like this:
And after recieve messages and handled its you will get an error:
After some research source code of
spring-amqp
I have explanation why it is happens:When we enable batch then used BatchMessagingMessageListenerAdapter
It is invokes invokeHandlerAndProcessResult method with
amqpMessage
=null
and after invokeHandler we get result asMonoOnAssembly
therefore we also call handleResult method where we basicAck will be called withrequest
as null (because above we pass it asamqpMessage
=null
).Expected behavior
No error occurs while using suspend
RabbitListener
withconsumerBatch
andAcknowledgeMode.MANUAL
The text was updated successfully, but these errors were encountered: