Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Choosing the right asynchronous-messaging infrastructure for the job

July 31, 2020
Bilgin Ibryam
Related topics:
JavaMicroservicesEvent-driven

    The term asynchronous means "not occurring at the same time." In the context of distributed systems and messaging, this term implies that request processing will occur at an arbitrary point in time. Asynchronous interactions hold many advantages over synchronous ones, but they also introduce new challenges. In this article, we will focus on specific considerations for choosing the asynchronous-messaging infrastructure for your event-driven systems.

    We will start by looking at the subtle differences between asynchronous interaction styles based on the business value and semantic type of the messages being delivered. Considering these differences helps us to identify messaging patterns, which we can use to determine the kind of messaging system that we need.

    Note: At Red Hat, we love any open source technology, so I use three open source messaging frameworks—Apache Qpid, Apache ActiveMQ Artemis, and Apache Kafka—for my examples. Red Hat AMQ is our flexible messaging platform that includes all three frameworks, making it easy to choose the right tool for your needs.

    The business value of different message types

    Not all messages are created equal. Some are valid and valuable only for a short period and become obsolete later. Some are valuable until they are consumed, regardless of how much time has passed. And some messages are valid and useful for repeated consumption. By considering the validity and value of messages relative to time and consumption rate, we can qualify interaction styles between services into three categories, as described in Figure 1.

    Figure 1: Understanding the business value of different message types.
    Figure 1: Understanding the business value of different message types.
    Figure 1: Understanding the business value of different message types.">

    Let's consider each of these categories.

    Volatile

    Messages in a volatile messaging system are ephemeral, and the value of the message is time-bound: They are valuable now, but soon they will not be. There is no point in storing events that will soon be useless. For this type of event, a volatile messaging system yields the best performance with the lowest possible latency as writing to the disk is skipped. In this type of scenario, the messaging system is aware of consumers and disseminates events to all consumers who are online at the time of publication. When consumers disconnect from the system, the messaging system forgets about them. This type of system is vital for its ability to handle a large number of dynamic clients that have low-latency interaction needs, such as Internet-of-Things (IoT) devices.

    Durable

    This more traditional type of message system knows about registered consumers and stores messages durably until every registered consumer has read them. This type of system works well for scenarios where the consumer might be disconnected when the event is published. The system holds on to the messages until every consumer has re-connected and consumed the relevant events. Once an event has been fully consumed, the message broker discards the messages. The goal is to offer reliable messaging among services with strong ordering and delivery guarantees.

    Replayable

    Here, the messaging system is not aware of consumers or event registrations. It merely stores events and publishes them to a stream for a given period, or until capacity is reached. In this type of system, an existing or new consumer can join at any time, connect and consume events, and even replay the stream from the beginning. Consumers can move back and forth in the stream as required. The driving force for this type of messaging system is scalability, combined with the ability to replay messages.

    Message semantics

    Apart from the technical characteristics of messages, it is essential to distinguish the language that we use—i.e., the semantic aspects—and the intent of the interactions. Some messages are targeted for a specific consumer and demand concrete actions. Some query the latest state of a system without requiring a state change, and some notify the world about a change that has happened in the source system. From a messaging-semantics perspective, there are three message types, as described in Figure 2.

    A graphic showing three message types based on semantics: Command, query, and event.
    message_semantics
    Figure 2: Understanding message types based on semantics.

    Let's consider each of these message types.

    Command

    A command is a request for action that usually leads to a state change on a known target system. Typically, a response indicates that the action was completed, and there might even be a result associated with the response. When a response is expected, commands are typically implemented over synchronous protocols such as HTTP. It is also possible to apply request-and-response or fire-and-forget command styles over asynchronous messaging systems. Command-based asynchronous messages require coupling between the source system and the target system, in the form of command semantics.

    Query

    A query is like a command, but it is a read-only interaction that does not lead to a state change. By nature, a query expects a response. It is common to see synchronous implementations of this message type, but asynchronous and non-blocking implementations over messaging systems are also typical. Even fire-and-forget interactions for long-running operations, where a response is written to a different location, are not unusual.

    Event

    An event is a notification that something has changed. A system sends event notifications to notify other systems of a change in its domain. An event is different from a command in that often the event-emitting system doesn't expect a response. In addition to being asynchronous, event messages are not targeted to a specific recipient, which makes further decoupling possible. Similar to other asynchronous interactions, events are implemented as messages on queues, which are often called streams.

    Note: See Martin Fowler's presentation, "The many meanings of event-driven architecture," for in-depth coverage of the different types of events in a messaging system.

    Choosing a messaging system

    The Law of the instrument approach defined by Abraham Maslow says, "If the only tool you have is a hammer, treat everything as if it were a nail." Following that approach, you could certainly use a classic message broker such as Apache ActiveMQ Artemis to implement the different interaction styles described in this article. The technology is familiar to many, which would make it easy to use from the start. On the other hand, it would be challenging to develop use cases such as replayable messaging with a classic message broker.

    On the other end of the extreme, you could try using something like Apache Kafka for every messaging scenario. Kafka would require a more substantial amount of hardware resources and human effort to manage, but use cases requiring replayable messaging or extreme scalability would be covered.

    While both of the above approaches are fine in some cases, when you have a large number of services with different messaging needs, using the right tool for the right job is a better option. Mapping the previously described messaging patterns is a useful tool for deciding what messaging infrastructure you need. In Figure 3, I have mapped the characteristics of three different types of message broker system to the different messaging scenarios and types of messages we've discussed.

    A chart for comparing messaging systems based business needs and message semantics.
    messaging_infrastructures
    Figure 3: Mapping messaging characteristics to messaging infrastructures.

    Each of the three frameworks in Figure 3 is effective for a different type of messaging scenario and need. As I mentioned at the beginning of this article, Red Hat AMQ packages all three of them—Apache Qpid, Apache ActiveMQ Artemis, and Apache Kafka—so that you can choose the right tool for the right job.

    Conclusion

    There are many aspects to consider when choosing the right event-messaging infrastructure for your needs. I hope that the considerations and the mapping tool presented in this article will help you get one step closer to deciding.

    Last updated: July 28, 2020

    Recent Posts

    • Red Hat Hardened Images: Top 5 benefits for software developers

    • How EvalHub manages two-layer Kubernetes control planes

    • Tekton joins the CNCF as an incubating project

    • Federated identity across the hybrid cloud using zero trust workload identity manager

    • Confidential virtual machine storage attack scenarios

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.