the listener container must have a MANUAL AckMode to populate the Acknowledgment
时间: 2024-03-05 17:52:31 浏览: 118
This error message usually occurs when using a Spring message listener container to consume messages from a message broker, and the Acknowledgment mode is not set to MANUAL.
In a Spring message listener container, the Acknowledgment mode determines how and when the message is acknowledged after it has been consumed. If the Acknowledgment mode is set to AUTO, the message is acknowledged automatically after it is consumed, without any further action required by the listener. However, if the Acknowledgment mode is set to MANUAL, the listener must explicitly acknowledge the message by calling the Acknowledgment.acknowledge() method.
So, if you encounter this error message, you need to make sure that the Acknowledgment mode is set to MANUAL for the message listener container. You can do this by setting the container's acknowledgeMode property to AckMode.MANUAL as follows:
```
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setDestination(destination);
container.setMessageListener(messageListener);
container.setAcknowledgeMode(AckMode.MANUAL);
container.start();
```
I hope this helps! Let me know if you have any more questions.
阅读全文