Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local vs. remote queues in pub/sub messaging

If I was building a system with dozens of publishers/subscribers using message queues, it seems I have a few network configuration options:

  1. I could have one clustered broker that all machines use - each machine would not have a local queue
  2. I could install brokers locally on every machine, and use store-and-forward to deliver messages to remote machines

Different technologies seem to enforce different configurations - e.g., MSMQ requires every machine to have its own local queue, while Tibco EMS seems to often be used in clusters, without local queues on each consumer.

What are the downsides to not having a local queue, and what factors influence the decision?

like image 399
Paul Stovell Avatar asked Sep 07 '11 20:09

Paul Stovell


People also ask

What is the difference between Pub/Sub and message queue?

In a message-queue model, the publisher pushes messages to a queue where each subscriber can listen to a particular queue. In the event-stream model using Pub/Sub, the publisher pushes messages to a topic that multiple subscribers can listen to.

What is the difference between message queues vs event streaming platforms?

While many consumers may be active, queues only deliver messages to a single consumer (typically whichever consumer is available to receive it first) before removing that message from the queue. Meanwhile, streaming brokers send the same message to every subscriber of that log file.

What is the difference between message queue and message broker?

Message queues provide a means for applications to push information to the queue. The message broker simply takes the information from the sender, translates it between different messaging protocols, if needed, and delivers the message to the correct receiver.

Is Pubsub a queue?

The Pub Sub queue (or Pub/Sub) is a message pattern of message brokers and it is used to communicate between the various components of microservices. It is used to provide program-to-program and asynchronous communication between the micro-services.


2 Answers

Not having a local queue that provides a durable message store means that you cannot guarantee message delivery. Using something like RabbitMQ in a cluster with a broker instance locally gives you a durable mechanism to store messages for delivery. If you have to connect over a network connection to a remote broker to send a durable message, you're at a higher risk of network failure.

MSMQ is also store-and-forward, but it doesn't provide any clustered routing capabilities. This means that the application has to do the work (or have a layer on top of it, such as MassTransit or NServiceBus do it for you).

When I think of TIBCO, I think of a centralized cluster of EMS servers that application servers communicate with instead of running a broker instance locally. The GUI tools that wrap around EMS and the BusinessWorks application servers really force a model in that world.

In any of the distributed cases where messages are stored locally, it's important to make sure the machine itself is properly equipped for message storage, with fast disk and sufficient disk for the expected message backlog/capacity.

like image 64
Chris Patterson Avatar answered Oct 29 '22 12:10

Chris Patterson


I would venture the local queue would be necessary in most scenarios.

The local queue is necessary if the message needs to be durable. In other words, if the connection to a remote queue is unreliable and you want the message to eventually reach its subscribers, you would want the store-and-forward capability of the local queue.

If the message does not need to be durable (can be lost after the firing of the event), then the remote shared queue would be an option.

You may want to look at the NServiceBus distributor model, which would be a hybrid of your two scenarios: a local queue on each machine to forward to a remote broker/distributor cluster.

like image 31
codeprogression Avatar answered Oct 29 '22 12:10

codeprogression