What is the difference between a message bus and a message queue?

Talk about the difference between the message bus and the message queue, and the need for the enterprise application to encapsulate the message queue into a message bus.

What is the difference between a message bus and a message queue? If someone asks you this question, what is your answer? If your message bus is based on an already mature message queue or messaging system, do the secondary encapsulation. Why do you need to use your client instead of using the original one? (This is an era where everyone believes in authority. Please note that this is faith instead of superstition. You really should believe authority, at least than rely on a newcomer. Spectrum, of course, the authority I refer to here is positive.)

Then I talk about my reflection on this issue from the following points:

Message queue clientAPI permissions too high, clientAPI trust level too high

Message queue clientAPI technology, message bus clientAPI technology + business

Message Queue Cannot Hide Communication Details

Message Queuing cannot implement real-time control

The advantages of the bus: unified entrance, simplifying the cost of interception

For the sake of simple understanding, let's consider RabbitMQ as a message queue for the time being. Actually, it is not just a message queue. Other message queues based on JMS can also be established to answer this question.

(1) The message queue clientAPI permissions are too high, the trust level is too high

This is not the case where the client driver of a server component is implemented. Most of them are like this. Their client is actually a translation of the server component (or server) protocol. Most of these servers have a commandline interface (this is almost standard). In fact, the CLI does not differ in essence from the client libraries of the various languages ​​used in the program. They are all clients in relation to the server. They are both translations and conversions of the protocol implemented by the server. These APIs are all for these. The call of the wrapped protocol. So they all have some interfaces in the form of "management": such as create, delete, remove a component, and so on. That's right, you look at the implementation of all the components with the client. They all include these APIs (this is not a right or wrong question, these clients themselves do not and should not assume your use scenario). For example, if you look at redis's client: jedis - it even has flushAll, flushDB functions (empty all redis data), what can't be done except to shut down the server? For RabbitMQ, its officialNTIve java client can create/delete the core components of its communication: exchange,queue. Can you distribute these clients directly to various business systems without blocking? You certainly need to do a secondary package to remove these high-risk management APIs.

(2) message queue clientAPI technology-oriented and message bus clientAPI technology-oriented + business

Most of the client APIs for message queues are protocol-oriented and communication-oriented. They are oriented toward availability and high performance. If they are classified, they are technology-oriented. In addition to communication scenarios, they do not simulate business scenarios. The message bus needs to take the business scenario to implement the mechanism that needs to be supported.

When you search for any message queue, there is one in its advantage: the producer is decoupled from the consumer, like this:

What is the difference between a message bus and a message queue?

In terms of producer and consumer models, this is indeed an advantage of message queues. However, this advantage is also limited to some specific usage scenarios, such as message queuing for a single service. Therefore, the universal message queue scenario is more applicable to the producer and consumer model of single responsibility; and the message bus we expect is the communication of messages in various systems in the enterprise, with an emphasis on communication. The message queue only provides an implementation mechanism (message ordering, message buffering, etc.) that is very suitable for message communication. Therefore, the message bus encapsulates a service scenario suitable for message interaction on the technical support provided by the message queue.

(3) The message queue cannot hide communication details

For system interaction within the enterprise, we want it to ensure data security as much as possible. The data is usually temporarily in the queue, so to ensure that the security of the data will naturally change to ensure the security of the message queue access: you should never allow unauthorized clients to access should not be accessible queue. Unfortunately, the official RabbitMQ client does not meet this requirement. To access a queue, you need to know the name of the real queue and need to know its routing path. In terms of connecting to a queue, we think it provides too much information, but this is no way, because its exchange and queue mashup mechanism is very flexible, so you have to provide a routing path called rouTIngkey . In any case, if you open this information to the caller to fill out, it will almost certainly reveal the routing mechanism and topology of your server exchange and queue. So what do we need to do? We need to find a communication mechanism so that it only needs to know that there is a proxy node in the outside, and it doesn't need to pay attention to the name of the real queue; then we want to find a way to hide its rouTIngkey inside the message bus.

(4) The message queue cannot be controlled in real time

If you introduce a message bus between systems in your enterprise, it is clear that access control must be provided. For example, the message size limit is enforced on a queue, a queue is activated/deactivated, and so on.

Earlier we mentioned that message queues are not business-oriented, and they do not have too much consideration for data security and access control mechanisms. And we can hardly transform the server-side implementation of a message queue, unless it is based on the interceptor/plugin mode. Even if RabbitMQ supports plug-ins, but for such an audience as erlang is not a very extensive language, you will go to the pit to write plug-ins to it, and RabbitMQ officials have stated that they do not recommend you to go Write plugins. Considering the inconvenience, we can only make a fuss on the client. There is no doubt that our real-time control information must still be stored on the server (but it is a separate server), but the native client obviously does not support this mechanism, so we need to wrap the subscription outside the native client in real time Manages information and implements access control logic.

(5) The advantages of the bus: unified entrance, simplifying the cost of interception

Whether it is a message bus or a service bus, in fact, the so-called bus is the process of first gathering and then divergence. Shoulong first, enter from the unified entrance, complete the necessary unified processing logic; then diverge, according to routing rules, routing to various components to deal with. In fact, this is the role of the agent: shielding internal details and external entrance. Based on the agent-based, we can log all the messages on the message bus (because all message communication must go through the proxy), and still on the basis of not cutting RabbitMQ's own Channel, and if you want to achieve routing A proxy, that basically can not be separated from a tree topology.

Write last

This article mainly discusses the difference between the message bus and the message queue. In fact, there are already some mature message queues on the market that can be used out of the box. If you encapsulate a message bus for message queues, some people will always think whether this is necessary or not. If you do not have these open source message queues, then you have to implement the message bus yourself, you still need to implement a similar MQ or Message Broker (see POSA volume 4) on the market, so the message queue is only the basis for implementing the message bus, Or it is its message communication method; and choosing to develop based on some mature Message Broker can not only save a lot of workload, but also enjoy the stability they provide and the community's contribution.

Advertising Digital Signage

The digital signage Advertising Player is a new generation of intelligent equipment that uses standard LCD displays and LCD TVs to realize information display and video advertisement playback through networking and multimedia system control. Outdoor LCD digital signage advertising machine replaces traditional light boxes, posters, and frames. An LCD advertising player can play multiple pictures and videos at the same time, making full and effective use of geographic technology locations. Save costs and better publicize and display products.

digital signage,digital signage outdoor,digital signage advertising,wall mounted digital signage,interactive kiosk,stretched lcd displays

Shenzhen Hengstar Technology Co., Ltd. , https://www.angeltondal.com