This article briefly introduces ActiveMQ from the following aspects
1. Background of message middleware
2. Briefly describe the JMS specification
3. Introduction to ActiveMQ
1. Background of message middleware
Currently, such as RMI, RPC middleware technology is applied to various fields, but in the face of increasingly complex distributed systems, the above middleware has the following limitations:
(1) Synchronous communication: After the client sends a request, it must wait for the server to complete the processing and return the result before continuing to execute;
(2) The life cycle of the client and the server is tightly coupled: the client process and the server process must run normally; if the client request is unreachable due to the crash of the server object or the network failure, the client will receive an exception message;
(3) Point-to-point communication: a call from a client can only be sent to a single target object;
Message-oriented middleware (Message Oriented Middleware, MOM) better solve the above problems. The sender of the message sends the message to the message server, the message server stores the message in several queues, and then forwards the message to the receiver when appropriate.
① In this mode, sending and receiving are asynchronous, and the sender does not need to wait;
②The declaration period of the sender and the receiver is not necessarily the same: the receiver does not necessarily run when the message is sent, and the sender does not necessarily run when the message is received;
③ One-to-many communication: there can be multiple receivers for a message;
2. Briefly describe the JMS specification
1. Java Message Service (JMS) defines the interface for accessing message middleware in Java. JMS is just an interface (specification), and has not been implemented. The message middleware that implements the JMS specification interface becomes the JMS Provider. The existing message middleware such as Apache's ActiceMQ, Ali's RocketMQ, IBM's MQSeries, Microsoft's MSMQ, etc., they are basically all Comply with the JMS specification.
2. JMS terminology
Provider(Message Provider): Producer
Consumer(Message Consumer): Consumer
PTP (Point to point): point-to-point message model
Pub/Sub: Publish/Subscribe, the publish-subscribe message model
Queue: Queue target
Topic: Topic target
ConnectionFactory: The connection factory that JMS uses to create connections
Connection: The connection from the JMS client to the JMS Provider
Destination: message destination
Session: Session, a thread that sends or receives messages
3. Definition of message format
JMS defines 5 different message body formats, as well as types of invocation messages, allowing you to send or receive data in some different forms, providing some level of compatibility with existing message formats.
(1) StreamMessage: java original data stream
(2) MapMessage: name-value pair
(3) TextMessage: a string object
(4) ObjectMessage: a serialized java object
(5) BytesMessage: data stream of bytes
3. Introduction to ActiveMQ
ActiveMQ is a popular message produced by Apache, a powerful message processing bus.
ActiveMQ is a JMS Provider implementation that fully supports the JMS1.1 and J2EE1.4 specifications.
If you want to have more powerful performance and processing capacity of massive data, ActiveMQ needs to be continuously upgraded. For more than 80% of the business, we can use ActiveMQ to meet the needs.