Springboot Integrated RABBITMQ Spring Event driven model

Source: Internet
Author: User
Tags rabbitmq

actual combat Background: Before entering RABBITMQ technical knowledge points, let's talk about the three components of Applicationevent, Applicationlistener and Applicationeventpublisher, which are closely related to the event-driven Click to see its source code can be found inside the use of cachingconnectionfactory, Applicationcontextaware and other components will be introduced to our RABBITMQ related components have a great relationship!

Actual combat Analysis : After the actual combat RABBITMQ each major technical points, you will be surprised to find that applicationevent can actually be understood as "message" (that is, messages), Applicationlistener is the same idea as RABBITMQ's listener (consumer listener), and Applicationeventpublisher is the equivalent of Rabbittemplate, which is the component used to send messages. and other like Applicationcontextaware and RABBITMQ's message confirmation mechanism have something like that

Actual combat communication : In the course of learning, if there are related problems, you can add my personal qq:1974544863 or text at the end of the code to add my personal XXX exchange, in addition, interested in children's shoes can be added XXX public number, will not be timed to push dry Oh!

Actual course : We still take "order record" as the actual business module, business process we define as follows:

  1. In the development process, my own habits are not related to the actual business, that is, to jump out of business thinking, first let the overall situation on the process, that is, in this business module, my overall situation should be: Create controller-> Create request method, write dead business data--Asynchronous send- > Asynchronous monitor to hear data--and subsequent logical processing.

  2. Based on the above-mentioned overall process, we first create an asynchronous message event that stores the order record information, then creates a listener to accept the information and process the business logic, and finally creates the controller to send the information. The associated event, listener already controller is as follows:



  3. In the above code, I would like to have a certain base of children's shoes can be understood, the general meaning is to create good news, and then use the Publisher component to send messages, and this message by "Order record" to act as, when responding to this controller, Naturally, the Publisher component sends this event, which is eventually heard and processed by the listener that specifically listens to the event, and the following run up, postman simulates the method of requesting the controller as follows:

  4. The above effect shows that the entire sending message and listening to the logic of consumer messages is a matter of wood, in addition, it is worth mentioning that this event can be bound by multiple listener, equivalent to a message in rabbitmq can be monitored by more than one listener. So after learning to rabbitmq the whole piece of knowledge, you will find that the spring event-driven model is a simple message model that RABBITMQ: "producer, send Message, queue, consumer monitoring consumer processing". As shown below:

  5. The following is the logic to consolidate the DAO layer of the database, and the data to be heard is inserted into the database table as follows:

  6. As a result, the spring event-driven model to be explained today is basically finished! With such a concept as the transition, I would like to open the RABBITMQ springboot integration of the actual combat wide can be much better!!

  7. Source Address Download: http://down.51cto.com/data/2451660
    Actual Combat Summary: This section is mainly to make a cushion or call the transition bar, the next section began to really enter the Springboot integration RABBITMQ the actual combat link! Actual combat process if there are related issues, you can add the contact information provided in the technical exchange! In addition, if you are interested in a complete video tutorial on RABBITMQ, you can add me qq:1974544863 for technical exchange or consultation details! Interested in children's shoes can pay attention to my XXX public number Oh!

Springboot Integrated RABBITMQ Spring Event driven model

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.