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:
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.
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:
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:
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:
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:
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!!
- 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