DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Applying Kappa Architecture to Make Data Available Where It Matters
  • Real-Time Stream Processing With Apache Kafka Part 4: Use Case
  • Non-blocking Database Migrations
  • Resilient Kafka Consumers With Reactor Kafka

Trending

  • Automated Testing Lifecycle
  • Selecting the Right Automated Tests
  • Automated Testing: The Missing Piece of Your CI/CD Puzzle
  • Getting Started With Prometheus Workshop: Instrumenting Applications
  1. DZone
  2. Data Engineering
  3. Big Data
  4. Comparing Publish-Subscribe Messaging and Message Queuing

Comparing Publish-Subscribe Messaging and Message Queuing

Messaging is a critical technology to execute the data pipelines that are a crucial part of application design. Learn about the different types of messaging.

Jon Bock user avatar by
Jon Bock
·
Jan. 19, 18 · Analysis
Like (8)
Save
Tweet
Share
83.58K Views

Join the DZone community and get the full member experience.

Join For Free

Building the data pipelines that move data from where it is created to all of the different places that it is processed is a fundamental part of designing and implementing data-driven applications. Messaging is a critical technology for connecting data in this environment.

In the data processing domain, messaging is the transmission of data records from one system to another via an intermediate system. In contrast to direct connections, where senders know the receivers to which data will be sent and connect directly to each receiver, messaging solutions decouple the sending of data from data consumption. Senders do not know which receivers will see that data or when they will see it.

Messaging solutions help simplify application development by providing a standardized, reusable component for robustly handling the data flows, enabling developers and architects to focus on the core logic of applications. In addition to routing data, messaging systems can also provide capabilities for logging, distributed processing, flow control and resiliency to improve performance, scalability, manageability, and reliability.

Messaging is a broad term that covers several models that differ based on how data is moved from senders to recipients. There are two primary categories of messaging models: message queuing and publish-subscribe (often referred to as pub-sub) messaging.

Message Queuing

Message queuing is designed for scenarios such as a task list or work queue. A message queue receives incoming messages and ensures that each message for a given topic or channel is delivered to and processed by exactly one consumer. An example scenario is issuing paychecks–it is critical that every paycheck is issued once and only once, but it does not matter which exact processor issues each check.

Message queuing example scenario

Message queuing example scenario.

Message queues can support high rates of consumption by adding multiple consumers for each topic, but only one consumer will receive each message on the topic. Which consumer receives which message is determined by the implementation of the message queue. To ensure that a message is only processed by one consumer, each message is deleted from the queue once it has been received and processed by a consumer (i.e. once a consumer has acknowledged consumption of the message to the messaging system).

Message queues support use cases where it is important that each message is processed (and only processed once), but it is not necessary to process messages in order. For example, in the case of network or consumer failures, the message queue will try resending an affected message at a later time (not necessarily to the same consumer) and as a result, that message may be processed out of order.

Publish-Subscribe Messaging

Like message queuing, publish-subscribe (commonly referred to as "pub-sub") messaging moves information from producers to consumers. However, in contrast to message queuing, publish-subscribe messaging allows multiple consumers to receive each message in a topic. Further, pub-sub messaging ensures that each consumer receives messages in a topic in the exact order in which they were received by the messaging system.

Publish-subscribe messaging example

Publish-subscribe messaging example.

Publish-subscribe messaging systems can support use cases in which multiple consumers receive each message and/or that messages are received in order by each consumer. For example, a stock ticker service can be used by a large number of people and applications, all of whom want to receive all messages (e.g. prices at which stock trades occur) on their topics of choice. It is important for these users that they receive messages in order–seeing a high price followed by a low price for a stock means something very different from seeing a low price followed by a high price.

Publish-subscribe use cases are frequently associated with stateful applications. Stateful applications care about the order of messages received because the ordering of messages determines the state of the application and will, as a result, impact the correctness of whatever processing logic the application needs to apply.

Technology Options

Not surprisingly, given how fundamental messaging is to data-driven applications, there are a number of technologies that support some form of message queuing, publish-subscribe messaging, or both.

Technologies such as Apache ActiveMQ, Amazon SQS, IBM Websphere MQ, RabbitMQ, and RocketMQ were initially designed primarily for message queuing use cases. Other technologies such as Apache Kafka and Google Cloud Pub/Sub were designed primarily to support publish-subscribe use cases. Other, often newer solutions such as Apache Pulsar provide support for both message queuing and pub-sub messaging.

Determining which technology is the best fit for a particular use case requires understanding the essential requirements for that use case--for example whether ordering is important and whether multiple consumers need to process each message. Each technology brings a different set of features and optimizations that need to be evaluated based on those requirements. Also important to evaluating technology options is understanding the ease of application development, performance, resiliency, and operational demands associated with the different technologies and how they are deployed.

kafka application Data processing IT Database Message queue IBM WebSphere Flow control (data) Use case

Published at DZone with permission of Jon Bock. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Applying Kappa Architecture to Make Data Available Where It Matters
  • Real-Time Stream Processing With Apache Kafka Part 4: Use Case
  • Non-blocking Database Migrations
  • Resilient Kafka Consumers With Reactor Kafka

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: