At present, various RPC middleware technologies have been widely used in various fields. Among them, the function of message communication between servers is widely used in these middleware, so the message-oriented middleware (messages oriented middleware, MOM) is abstracted to form common message middleware and become the mainstream of the industry. At present, the standard of message middleware includes: JMS and AMQP. The realization is to blossom.
Message middleware needs to address the following issues in terms of functionality:
1. Synchronous or asynchronous message transmission, especially asynchronous message transmission
A synchronous send message is whether the blocking wait message sends a successful feedback after the message is sent, and if the setting has a time-out, the timeout is out of the blocking state.
An asynchronous send message is a message that does not block immediate execution of other actions. If you care whether the message was sent successfully, you can handle the message successfully through the callback function (Listener in Java).
2. Message security, message middleware for persistent support
In a distributed system, messages are sent to receive, there are so many links, there is no one link is safe, and any link out of the problem, will cause lost messages. When there is a need, we must ensure that the message is securely transmitted in multiple links that are not absolutely secure. Among these, the persistence of the message is very important.
3. The postback of the message
This is not required if you are using a system that guarantees power. Otherwise, some scenarios require that messages not be sent back. It is very difficult to keep the message secure and not to send the message back. At present, no one in the industry can solve this problem.
At present, in the case of a message to be sent, the system using the state machine is used to ensure the power of the system to the message.
4. The Order of messages
If the system you are using has requirements, you may need to guarantee the order of messages. In large-scale distributed unreliable environment, it is very difficult to solve this problem in the case of guaranteeing message transmission efficiently and message security.
If only a small scale system, the performance requirements are not high, you can use the server time, the queue can be used to solve.
If the sending end time is the same, and the message in order is sent by this sender, the message number is used to resolve it.
In addition, some systems only need to satisfy the local message order, in the case of a small number of sorted messages, you can use more than one sort message to send the resolution.
5. Message transfer model: Point-to-Point transmission message (PTP), subscription/publishing model (PUB/SUB)
PTP is the unique identifier that you set the message receiver on the message side, and then the message sender and the message receiver establish a one by one correspondence. The message sender sends all messages that are received by the message receiver.
Pub/sub, is the message sender and the message receiver both determine their own send and receive the message label (or you can understand as group GroupID), all have this tag message, subscribe to this tag message receiver must be able to receive.
JMS (Java messaging Services, Java Message Service) is a message-oriented middleware specification dedicated to EE. It mainly makes the specification on the interface, the message transmission model and the message type specification, and does not give the realization. Similarly, it does not give a server-side architecture, and you can even transfer messages directly between clients without using the server (although the end result may be just a toy). Http://java.sun.com/products/jms/docs.html. JMS also does not specify the order of messages, security, and other characteristics of the postback.
AMQP (Advanced Message Queuing protocol, the Advanced message Queuing Protocol) is a language-independent, emerging messaging middleware used in the financial industry, and is now the focus of message middleware circles. Unlike the JMS specification API, it is an Application layer protocol specification used by asynchronous messaging. The original purpose of AMQP is to provide the financial community with a message protocol that can collaborate with one another, and the goal now is to provide common build tools for common Message Queuing architectures. http://www.amqp.org/
The current open source message queue has: Kafka generally used for log collection, ROCKETMQ,RABBITMQ, Taobao Open source distributed message middleware Metamorphosis, message middleware is divided into push mode and pull mode, push mode: push to consumers on OK, Pull mode: Consumer active rotation Message queue, micro-service system development message Asynchronous processing is an indispensable link