Spring AMQP Source Analysis 06-Manual Message Confirmation

Source: Internet
Author: User
Tags rabbitmq

# # Ready# # Target Understanding Spring AMQP How to manually confirm that a message has been successfully consumed # # pre-Knowledge "Spring AMQP source Analysis 04-messagelistener"# # Related Resources Offical doc: gordon.study.rabbitmq.springamqp.AsyncConsumerManualAck. Java # # # # # # # # # # # # # # Manual message Acknowledgement implementation for manual message Acknowledgement mode (acknowledgemode.manual)Spring AMQP chooses to have the developer call the RabbitMQ Java client's basicack method acknowledgment message in the message processing logic itself. the MessageListener interface cannot meet the requirements because the onMessage callback method cannot get the Channel object. Spring AMQP provides the channelaware MessageListenerinterface whose OnMessage callback method contains the Channel parameter, which can be used to confirm the message manually.  The example code line 25th Simplemessagelistenercontainer The message confirmation mode to MANUAL, and the 28th row implements Channelawaremessagelistener interface, consumes the message in the OnMessage callback function, and calls on line 33rd Basicackmethod to confirm the message. The call stack is very similar to the previous one: # # message conversion? When usingMessageListenerInterface or Channelawaremessagelistenerinterface, the framework has not done any message conversions. The sample code creates a scornmessageconverterwith an error and sets it to Simplemessagelistenercontainer. From the program printing is visible,scornmessageconverter is never used. This is also obvious, after allOnMessageThe parameters that are accepted by the callback method areMessageType, there is no need for conversions at all.

Spring AMQP Source Analysis 06-Manual Message Confirmation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.