Message Queues (2024)

For a distributed system to work, it has to move information from machine to machine. No single machine is responsible for the system as a whole. But yet all information is somehow related to all other information. So it stands to reason that a major concern of distributed system infrastructure is moving data to the machines that need it. This also ends up being one of the most significant challenges.

Remote procedure calls

The simplest way to move information from one box to another is through a remote procedure call (RPC). An RPC models the way that code calls functions in a program. The caller passes a packet of information to the recipient as parameters. It then waits for the recipient to do whatever it needs to do, even if the recipient is going to call another procedure. And then the recipient returns another packet of information in the results. This model works fine for programs, but it has some drawbacks in distributed systems.

RPCs are synchronous. The calling machine allocates some resources, typically a thread, that stand waiting for the recipient to respond. Sometimes the request is a query, where the caller is waiting for the results before it can continue processing. Other times, it is a command, informing the recipient that it needs to take action. Even if the call is a command that returns void, the caller must wait for the response. If it doesn’t receive the response, it doesn’t know that the intended recipient received the call. So it has to either fail the request or retry the RPC.

RPCs are also unreliable. A local method call in a program cannot typically fail to reach the recipient. But a remote procedure call can get dropped, it can time out, or it can be corrupted. This might not just happen to the request, but also the response. If the call fails, the caller has no way of knowing which was lost. If it was the request, then a retry would be safe. But if it was the response, then a retry might lead to duplication.

Advantages of message queues

Message queues address both of these problems. First, they are asynchronous. After the message has been queued, the caller doesn’t wait for it to be processed. It can free up that thread for handling additional work. If the caller expects a response, then the caller must pull response messages from a second queue. While this complicates matters, we have tools (for example sagas) to address this new complexity.

Message queues are also reliable. Once the sender is sure that the message is in the queue, it can be confident that it will be received once and only once. Message queues typically have a two-phase API for receipt: first the recipient gets the message, and then it commits. If a problem occurs before the commit phase, then the message is “put back on” the queue (in actual fact, it never truly left; it only looked like it did). This two-phase receipt ensures that a message will be processed once and only once. It is no longer the concern of the sender.

Disadvantages of message queues

Message queues and RPCs do have one feature in common. They are both one-to-one in nature: they transmit information from one sender to one recipient. Like a caller of an RPC, the message sender has some idea about the system for which the message is intended. A queue is not a broadcast mechanism. When one recipient receives the message, it is no longer available for others to pick up. We have additional tools (for example dispatchers) to support one-to-many scenarios.

Message queues create additional operational complexity. Every queue must be created, configured, and monitored. Every sender and recipient must be configured with the location and name of each queue. We have created tools (for example service busses) to manage this complexity, but they do not eliminate it entirely.

Message queuing in historical modeling

Historical modeling puts the idea of the message queue into the model itself. Every fact is potentially a queue. A subsequent fact can be published to this predecessor.

Take, for example, a medical claims processing service.model

Message Queues (1)

fact Physician { unique;}fact Patient { unique;}fact Visit { Physician physician; Patient patient; date dateOfService;}fact Payer { unique;}fact Claim { publish Payer payer; Visit visit;}

In this model, the Payer fact acts as a queue. A Claim is published to that queue. This is indicated in the factual code with the publish keyword, and in the diagram with a red arrow.

When the payer processes the claim, it responds with a remittance advice.model

Message Queues (2)

fact RemittanceAdvice { publish Claim claim; decimal amount;}

The RemittanceAdvice fact is published to the Claim. The practice subscribes to the claim in order to receive the response.

To make the Payer act as a queue, it needs to query for all of the unprocessed claims:

fact Payer { unique; Claim* unprocessedClaims { Claim c : c.payer = this where not c.processed }}

The query depends upon the processed predicate:

fact Claim { publish Payer payer; Visit visit; bool processed { exists RemittanceAdvice a : a.claim = this }}

Adding a RemittanceAdvice causes the processed predicate to become true, thus removing the Claim from unprocessedClaims.

Advantages of historical message queues

The historical modeling message queue pattern has some advantages over traditional message queues. Most significantly, the queue is no longer coupled to a physical location. The practice didn’t know the location or name of the payer’s queue. Neither did the payer know the location of the practice. As long as the sender and recipient share a common upstream server, the claims and remittance advice will flow to the interested parties.

We also have the advantage of creating queues on the fly with no operational overhead. We can add a new payer to the system as easily as creating a new object. Each payer’s service subscribes to its own queue, without the need for configuration. And consider the operational nightmare of configuring a new response queue per practice, let alone per claim as we’ve done in this model.

Disadvantages of historical message queues

On the other hand, historical modeling has one significant disadvantage as compared to message queues: it is impossible to ensure that only one recipient handles each message. The two-phase receipt of a traditional message queue lets one service lock a message. Other services pulling work from the same queue will not receive it unless the first service fails. This is an effective technique for load-balancing backend services.

The rules of historical modeling forbid locking. To balance the load among competing backend systems, you must bridge a historical model into a more traditional message queue. The bridge pushes a message onto the queue for each unprocessed fact, and then creates a new fact marking it as received. This bookkeeping fact is not intended for application use, and is typically not published. The historical database and the message queue must be compatible so that they can participate in the same transaction, thus ensuring reliability.

Conclusion

Message queues offer significant advantages over RPCs in distributed systems. Whereas RPCs are synchronous and unreliable, message queues are asynchronous and reliable. They add complexity both to application design and operations, but that complexity can be managed.

Historical modeling supports the concept of a message queue through the publish keyword, predicates, and queries. It can ease some of the operational complexity, since it decouples senders and recipients from queue location. And since any fact can be a queue, operational overhead is not incurred to add a new queue. However, historical modeling does not support locking, so additional work is required to implement a load-balancing scenario.

Message Queues (2024)

FAQs

Message Queues? ›

Message Queues

What is a message queued? ›

If any of your emails are showing up as “Queued” in your outbox folder, it means that it is in the process of being sent. In other words, Gmail was not able to send that email immediately for some reason, so it will try again later.

What does it mean when a text message says queued? ›

If your recipient exceeds their limit, your messages may be queued up, causing them to arrive late or not at all in extreme cases.

What is an example of messaging queuing? ›

Some examples of message queues are Apache Kafka, RabbitMQ, and LavinMQ, among others. We can generally use a message queue to allow the services within a microservice to communicate asynchronously.

Is Kafka a message queue? ›

Kafka and RabbitMQ are message queue systems you can use in stream processing. A data stream is high-volume, continuous, incremental data that requires high-speed processing.

How do I fix a queued message? ›

To resolve the queued emails in Gmail, ensure you have a stable internet connection and try manually sending the messages by opening the "Outbox" or "Sent" folder and clicking on the "Send" button next to each message. If the issue persists, restarting the Gmail app or your device might help.

What do message queues do? ›

Message queues enable asynchronous communication, which means that the endpoints that are producing and consuming messages interact with the queue, not each other. Producers can add requests to the queue without waiting for them to be processed. Consumers process messages only when they are available.

What does "queue" mean in texting? ›

Queue comes from the Latin cauda, for "tail." Outside the United States it means a line of people or vehicles waiting their turn, so if your English friend talks about queuing up for the movies, that means getting in line for a ticket. We also use it in computing to mean an order of messages to be sent.

How do I get queued messages to send? ›

How to Send a Queued Email in Gmail
  1. Go to Gmail and sign in.
  2. In the search bar, type 'in:outbox' to see all the emails in your outbox.
  3. Open the one you want to send.
  4. Click 'Send. '
Feb 8, 2023

What does queued mean on my cell phone? ›

Have you ever come across a “queued” message in Gmail when sending emails from your Android device? It's an issue that discriminately affects Androids, but what does it mean, and how do you fix it? When the Gmail app marks something as queued, it means that it's not able to send the email immediately.

Are message queues good? ›

They offer an array of benefits to developers and system administrators alike, including the following: Reliable message delivery: Using a message queue can ensure that business-critical messages between applications will not be lost and that they will only be delivered to the recipient once.

How do I check my message queuing? ›

In the Computer Management window, expand the Services and Applications node from the left-side panel. The Message Queuing will be available there.

What is the message queuing feature? ›

Features of Message Queues
  • Push or Pull Delivery. Most message queues provide both push and pull options for retrieving messages. ...
  • Schedule or Delay Delivery. ...
  • At-Least-Once Delivery. ...
  • Exactly-Once Delivery. ...
  • FIFO (First-In-First-Out) Queues. ...
  • Dead-letter Queues. ...
  • Ordering. ...
  • Poison-pill Messages.

Is message queue an API? ›

MQ's are distinct from APIs. APIs require both sides to be free to talk, while an MQ allows one side to send when it's able and the other to read when it's able which can happen out of sync.

Is message queue a server? ›

A message queue is a form of asynchronous service-to-service communication used in serverless and microservices architectures. Messages are stored on the queue until they are processed and deleted. Each message is processed only once, by a single consumer.

What is the difference between message queues and message broker? ›

Message Broker: Best suited for complex, large-scale systems requiring advanced message processing and integration capabilities. Message Queue: Optimal for straightforward, reliable message storage and delivery in a wide range of applications.

What causes an email to be queued? ›

Quite possibly the biggest culprit for queued emails is a weak or dropped network connection. If you tried to send an email but had connectivity issues, either on wifi or a mobile network, your email could wind up queued rather than going out. Gmail won't send without a stable connection to a mail server.

Why is my message in queue? ›

The queue can hold messages when the receiving application component, called a consumer or receiver, is busy, offline, or processing messages at a slower rate than they are being sent.

Why do I get queued? ›

In Gmail, “queued” means that an email you tried to send is stuck on a waiting list. For some reason, Gmail wasn't able to send it right away. In most cases, queued emails will eventually get delivered without any problems. But if you're worried, you can try troubleshooting the issue.

Top Articles
How to Register on Coinone (Guide for Foreigners)
Ultimate Gathering Trophy
Pollen Count Los Altos
Ron Martin Realty Cam
Ups Stores Near
Libiyi Sawsharpener
Restored Republic January 20 2023
Lamb Funeral Home Obituaries Columbus Ga
Western Union Mexico Rate
Readyset Ochsner.org
Mcoc Immunity Chart July 2022
Craigslist Greenville Craigslist
O'reilly's Auto Parts Closest To My Location
Learn2Serve Tabc Answers
D10 Wrestling Facebook
Money blog: Domino's withdraws popular dips; 'we got our dream £30k kitchen for £1,000'
Define Percosivism
Nhl Wikia
Aldine Isd Pay Scale 23-24
Golden Abyss - Chapter 5 - Lunar_Angel
3476405416
Marine Forecast Sandy Hook To Manasquan Inlet
Why do rebates take so long to process?
Theater X Orange Heights Florida
Busted Mcpherson Newspaper
Pocono Recird Obits
MyCase Pricing | Start Your 10-Day Free Trial Today
Craigslist Hunting Land For Lease In Ga
Soul Eater Resonance Wavelength Tier List
Xpanas Indo
Safeway Aciu
Black Lion Backpack And Glider Voucher
The Procurement Acronyms And Abbreviations That You Need To Know Short Forms Used In Procurement
The value of R in SI units is _____?
Moses Lake Rv Show
Watchseries To New Domain
450 Miles Away From Me
Los Garroberros Menu
Body Surface Area (BSA) Calculator
Leena Snoubar Net Worth
Stewartville Star Obituaries
Coroner Photos Timothy Treadwell
Tfn Powerschool
Booknet.com Contract Marriage 2
Dickdrainersx Jessica Marie
Pgecom
Theater X Orange Heights Florida
Playboi Carti Heardle
Dineren en overnachten in Boutique Hotel The Church in Arnhem - Priya Loves Food & Travel
Bradshaw And Range Obituaries
Pelican Denville Nj
Latest Posts
Article information

Author: Greg O'Connell

Last Updated:

Views: 6170

Rating: 4.1 / 5 (42 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Greg O'Connell

Birthday: 1992-01-10

Address: Suite 517 2436 Jefferey Pass, Shanitaside, UT 27519

Phone: +2614651609714

Job: Education Developer

Hobby: Cooking, Gambling, Pottery, Shooting, Baseball, Singing, Snowboarding

Introduction: My name is Greg O'Connell, I am a delightful, colorful, talented, kind, lively, modern, tender person who loves writing and wants to share my knowledge and understanding with you.