First of all, when doing any technical pre-Research: what will I do to clear it? Why use it?
What is JMS?
Java Message Service is a set of interfaces and related semantics. It defines how JMS customers can access the functions of Enterprise message generation.
JMS supports two transmission modes of message-oriented middleware: point-to-point and pub/Sub ).
JMS message model:
Header: a jms header contains many fields. After a message is sent, it is generated by the JMS provider or message sender to indicate the message, set priority and expiration time, determine the route for the message.
Property: it is generated by the message sender and used to add and delete additional information other than the message header.
Body: the message body is generated by the message sender. Five types of message bodies are defined in JMS: bytemessage, mapmessage, objectmessage, streammessage, and textmessage.
Why use JMS?
- A message is a distributed low-coupling communication solution. Producer A sends a message to the agent, and consumer B obtains the message on the agent. However, a and B do not need to register with the agent at the same time, the agent provides efficient communication services.
- Security. Because AB is not associated, the restart and exit of one party will not affect the other.
- Integrity judgment of messages. messages can be lost without strict transaction requirements.
Currently, most of the systems I work with are developed by one module per person and accessed through the HTTP interface. There are multiple user registration portals and user registration events are also assigned to different codes, which looks quite uncomfortable. Therefore, we decided to use JMS to process the logic after event triggering, reduces system coupling and facilitates code development and modification.
- The installation and configuration of activemq will not be described here. You can search for information on the Internet.
- The configuration files for activemq and spring collections are as follows:
Introduction to JMS Apache activemq (message-oriented middleware)