Difference between Message Queue and Message Bus?
It is one of the common question I often come across while I am chatting with my friend or searching something on the Internet. I will try to explain these two confusing terms to you in this article.
Definition of message queue is to receive bunch of messages from one application and to deliver them to one or more other applications on a first-in-first-out (FIFO) basis. Each application might have its own queue. Events that created from one application writes certain a queue.
Message queues consist of publishers and consumers. What we call publishers leaves messages to the queue. Consumers also receives them and processed. These are common patterns is used distributed systems.
These are the most well-known and being used as message queue; RabbitMQ, Kafka, ActiveMQ, AmazonSQS, IronMQ, Redis.
If Application 1 needs to send a message to Application 4, the message is written Queue A. As you see one more application can write the same queue. Message type does not need to be the same. You can manage it inside the consumer application. In fact, it connects two different services.
Message Bus may also come across under the name Service Bus. The Message bus provides us a messaging infrastructure for one or more applications to communicate messages to one or more other applications.
Message Bus does not guarantee first in first out. Subscribers subscribed to Message Bus can receive published messages without knowing about the publisher. These patterns also is known as pub/sub.
The message is published to the bus by the sending API, then any receiving API that has subscribed to any type of message will receive the corresponding message.
These are also the most well-known and being used as message queue; Microsoft Azure Service Bus, Oracle Enterprise Service Bus, Rabbitmq(MassTransit)
Publisher applications deliver their own state updates to the message bus. Subscribers who need this message receives this state updates from the message bus.