Skip to content

Consumers

A Consumer (also known as a Subscriber) is any client application that receives messages from FlowMQ. Unlike producers, consumers do not interact with topics directly. Instead, a consumer attaches to a specific entity—a Queue, a Stream, or a Subscription—to receive messages.

This design allows the consumer's role to be highly specialized. A consumer designed to process tasks from a queue operates differently from one designed to read an event log from a stream.


The Three Consumer Models

FlowMQ provides three distinct models for consumption, each tied to a specific entity.

1. Queue Consumers (The Worker)

A consumer that connects to a Queue acts as a worker in a pool.

  • Pattern: Competing Consumers. Messages are load-balanced across all consumers connected to the same queue.
  • Delivery: Each message is delivered to exactly one consumer.
  • Acknowledgment: The consumer must acknowledge (ack) each message after it has been successfully processed. This ack signals the broker to delete the message. If an ack is not received, the message will be redelivered to another worker.
  • Use Case: Distributing tasks, background job processing, request-response systems.

2. Stream Consumers (The Reader)

A consumer that connects to a Stream acts as an independent reader of a persistent log.

  • Pattern: Independent Consumption. Multiple consumers (or consumer groups) can read the same stream without impacting each other.
  • Delivery: Messages are delivered based on the consumer's current position (offset).
  • Acknowledgment: The consumer must commit its offset to track its progress. This tells the broker where the consumer should resume reading from if it disconnects and reconnects. Messages are not deleted after being read.
  • Use Case: Event sourcing, data analytics pipelines, audit logging, replaying historical data.

3. Subscription Consumers (The Subscriber)

A consumer that connects to a Subscription acts as a real-time subscriber in a pub/sub system.

  • Pattern: Fanout/Broadcast. Every message is broadcast to every active consumer connected to the subscription.
  • Delivery: Messages are delivered in real-time. If a consumer is not connected when a message is sent, it will miss it.
  • Acknowledgment: Consumers do not acknowledge messages. The delivery is "fire-and-forget," prioritizing low latency over guaranteed delivery.
  • Use Case: Live notifications, chat applications, real-time dashboards.

Summary of Consumer Models

FeatureQueue ConsumerStream ConsumerSubscription Consumer
Primary GoalWork DistributionEvent Streaming / ReplayReal-time Fanout
Message DeliveryTo exactly one consumerTo all consumer groupsTo all active consumers
DurabilityHigh (Messages persist until ack'd)High (Messages persist by retention)Low (Ephemeral, no persistence)
State ManagementNone (Broker manages state)Consumer commits offsetNone (Stateless)
Required ActionAcknowledge messageCommit offsetNone
Typical Use CaseTask processing workersAnalytics / Audit servicesLive UI clients / Apps