Event Streaming with Kafka

Kafka Producers Consumers The Message Flow

What is a Kafka Consumer

In Apache Kafka, consumers are the applications or services that subscribe to Kafka topics and process the incoming event streams. While producers push data into Kafka, consumers retrieve and act on those records—updating displays, triggering workflows, or writing results to other systems.

Role of an Apache Kafka Consumer

A Kafka consumer’s primary responsibilities include:

  • Subscribing to one or more topics.
  • Continuously polling brokers for new records.
  • Processing the payload (e.g., updating a database or UI).
  • Triggering downstream actions or alerts.

Consider an EV charging station scenario:
When a vehicle arrives, the station’s sensor sends an “occupied” event to Kafka. A consumer listening on that topic picks up the message and updates the mobile app in real time, reducing the available charger count.

Warning

Apache Kafka is optimized for event streaming with configurable retention policies. It is not intended as a long-term or archival database.

Connecting Your Consumer to Kafka

To start consuming events, configure these core settings:

ConfigurationPurpose
bootstrap.serversBroker addresses for establishing connections
group.idConsumer group identifier for load-balanced fetching
topicsOne or more Kafka topics to subscribe and poll

Once configured, your consumer will:

  1. Join the specified consumer group.
  2. Fetch assigned partitions.
  3. Poll each partition in offset order—never deleting data, only reading it.

Note

You can reset consumer offsets to replay historical data if it’s still within Kafka’s retention window.

Key Features of Kafka Consumers

FeatureDescription
Sequential AccessReads records in offset order within a partition—guaranteeing strict order.
Partition IndependenceProcesses partitions in parallel; ordering only applies per partition.
Historical ControlSupports offset resets to replay events, subject to retention policies.

The image describes three features of a Kafka Consumer: Sequential Access, Partition Independence, and Historical Control, each with a brief explanation.

Pull Architecture & Speed Management

Kafka’s consumer model is pull-based: consumers request batches of messages from brokers, giving fine-grained control over:

  • Throughput: adjust max.poll.records or batch size.
  • Latency: tune polling intervals and timeouts.
  • Back-pressure: throttle fetch requests to match processing speed.

The image is an infographic about Kafka Consumer, highlighting "Pull Architecture" and "Speed Management" with brief descriptions of each concept.

By pulling data on demand, consumers avoid overload and align ingestion with processing capacity.


Next Steps

In the next section, we’ll walk through setting up a Kafka consumer client in code and demonstrate consuming messages from your topic.

Watch Video

Watch video content

Previous
Producer Acknowledgments Acks and Reliability Guarantees