What is the difference between message queue and message broker?
Asked Answered
E

5

54

From what I understand, a message queue helps with inter-process communication, but it is limited to basically allow communication between only 2 applications? I'm asking this because for example MSMQ (if my understanding is correct) only stores the message in the queue until it is processed by the first consumer, after which it will be automatically removed from the queue. Is this correct ?

Now message brokers are some sort of extension to message queue in that they provide a mechanism of a pub-sub relation, something like the observer does. Is my understanding correct ? If so, are there any other differences between the two? Also why would you want to use a message queue over a message broker since you will most likely use a distributed system which more than certainly will be composed of multiple services.

Export answered 27/4, 2018 at 11:58 Comment(1)
Please add more details into your request . Without any relationship to an exact software product these words are meaningless. Technically these are parts of same system where "queue" or a "bus" is a place where your data pieces are stored and consumed from. This could be an address in some sort of database. The broker is an agent in such system that deals with all kind of aspects such as data access, data format configuration, routing rules, triggers etc. Most of the time a broker is a message server. Message queue can be also a part of programming interface for IPC.Nealy
P
61

A message queue is a data structure, or a container - a way to hold messages for eventual consumption. A message broker is a separate component that manages queues.

Postpone answered 28/4, 2018 at 14:49 Comment(0)
R
23

A message broker (also know a service bus) is a piece of middleware responsible with persisting and routing of message while allowing you to decouple your system into smaller parts. A message queue is a part of a message broker and is just a persistence mechanism.

Rawley answered 1/8, 2020 at 14:13 Comment(0)
A
5

From https://www.ibm.com/cloud/learn/message-brokers :

A message broker is software that enables applications, systems, and services to communicate with each other and exchange information. The message broker does this by translating messages between formal messaging protocols. This allows interdependent services to “talk” with one another directly, even if they were written in different languages or implemented on different platforms.

Message brokers are software modules within messaging middleware or message-oriented middleware (MOM) solutions. This type of middleware provides developers with a standardized means of handling the flow of data between an application’s components so that they can focus on its core logic. It can serve as a distributed communications layer that allows applications spanning multiple platforms to communicate internally.

Message brokers can validate, store, route, and deliver messages to the appropriate destinations. They serve as intermediaries between other applications, allowing senders to issue messages without knowing where the receivers are, whether or not they are active, or how many of them there are. This facilitates decoupling of processes and services within systems.

In order to provide reliable message storage and guaranteed delivery, message brokers often rely on a substructure or component called a message queue that stores and orders the messages until the consuming applications can process them. In a message queue, messages are stored in the exact order in which they were transmitted and remain in the queue until receipt is confirmed.

Astrakhan answered 23/6, 2022 at 23:50 Comment(0)
C
1

A message queue facilitates communication between applications by sending, receiving, and storing messages using the queue data structure. Even though we use message queues for data transfer, they can’t read the information they are carrying.

A message broker is simply a mechanism that extends the usage of message queues. Unlike message queues, message brokers can read the contents of the information carried through them. Also, message brokers can process information from all sorts of sources. For example, information read from files or HTTP requests.

In short, the message broker is responsible for: The conversion between data transport protocols The transformation of message formats between services The routing of the communication between services The distribution of events from various sources As it turns out, message brokers use message queues to transmit information between all interested parties. Simply put, the message queue is a structure that stores the produced data until its consumption, and the message broker is a software component that manages the message queues.

Concierge answered 12/10, 2022 at 12:30 Comment(0)
E
1

Message Queue(MQ), Message Bus(MB) and Message Broker are all middleware frameworks for app to app communication. These components are technology agnostic in a sense they don't care about how the application was implemented(Java, python, ruby etc). Different applications talk different languages and by nature cannot communicate with other application unless they perform the tedious task of translation themselves. Middleware components exist to take away this friction and lets applications talk with each other seamlessly

Differences Message Queue(MQ) Vs Message Bus(MB) Vs Message Broker To understand the differences, we can club Message Queue(MQ) and Message Bus(MB) together and keep Message Broker separately. The reason being there is only a slight difference between MQ and MB.

Message Queue & Message Bus These are essentially distributors of messages between applications. They receive messages in simple formats(text, xml, json) from publishers and allows valid subscribers to consume these messages. Because the components have persistency build inside them, it allows for guaranteed delivery in case of message loss. The Message Queue differs from Message Bus in that it ensures FIFO order when it stores messages locally. Order of delivery is maintained here. Message Bus simply does not care about the order of messages. For example, If you are travelling in a bus, the first person to enter the bus does not necessarily have to leave first. He might actually be travelling to the last destination. Similarly, in a Message Bus, you can write logic to send Messages with different priorities and order

Message Broker We can say Message Broker is the bigger brother. While MQ and MB simply store messages and deliver to valid clients, Message Broker does the extra job of translating between systems and also sometimes encapsulates routing and business logic. You have a lot more control over app to app communication using Message broker. It also supports more input/output formats other than simple text/xml/json

Eben answered 27/6, 2023 at 2:1 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Kern

© 2022 - 2024 — McMap. All rights reserved.