Course contentsShow
← Computer Science
Lesson 2708 of 2,87260. Distributed Data and CommunicationFree lesson

Point-to-Point vs Publish-Subscribe Models

Comparing one-to-one queue delivery with one-to-many topic-based broadcasting patterns and their use cases.

Point-to-Point vs Publish-Subscribe Models

What You'll Learn

You'll understand the fundamental difference between one-to-one queue delivery and one-to-many topic-based broadcasting in distributed messaging systems.

The Two Core Messaging Patterns

Building on message queue fundamentals, distributed systems typically implement one of two messaging patterns, each suited to different communication needs.

Point-to-Point (Queue Model)

In the point-to-point model, messages are sent to a queue where exactly one consumer processes each message. Think of it like a ticket support system: when a customer submits a ticket, exactly one support agent should handle it—not multiple agents working on the same issue.

Characteristics:

  • One producer sends to a queue
  • Multiple consumers may listen, but only one receives each message
  • Messages are typically removed after consumption
  • Load balancing across consumers happens automatically

Use cases: Task distribution (work queues), job processing, order fulfillment, ensuring idempotent operations where duplicate processing would be problematic.

Publish-Subscribe (Topic Model)

In the publish-subscribe model, messages are published to topics, and all subscribed consumers receive a copy. It's like a radio broadcast: when a station transmits, every listener tuned in receives the same content simultaneously.

Characteristics:

  • Producers publish to topics (not queues)
  • Multiple subscribers can listen to the same topic
  • Each subscriber gets its own copy of every message
  • Decouples publishers from subscribers completely

Use cases: Event notifications, real-time updates (stock prices, sports scores), logging/monitoring where multiple systems need the same data, fan-out patterns where one event triggers many reactions.

Choosing Between Them

Use point-to-point when you need exactly-once processing and work distribution. Use publish-subscribe when multiple independent systems need to react to the same events.

Key Takeaway: Point-to-point ensures one consumer handles each message (competing consumers), while publish-subscribe broadcasts messages to all interested subscribers (independent consumers)—choose based on whether you need work distribution or event notification.