# What happens when you send a message to Kafka

> One keyed order followed through Kafka: partition, leader, offset, copies, and the offset a consumer group commits.

Source: https://fullbytedeveloper.com/blog/what-happens-when-you-send-a-kafka-message
Published here: 2026-11-17
Tested: 2026-11-16, Apache Kafka 4.1.0 (1 KRaft controller + 3 brokers) in Docker 29.4.0 on macOS 27.2

Kafka keeps every message in a log, and reading a message does not remove it, so a second service can still read it later [1]. This page follows one order through a three-broker cluster, with the numbers from the run shown in the video: Apache Kafka 4.1.0 in Docker, three brokers and one KRaft controller, recorded on 2026-11-16.

## Create a topic with three partitions

A topic is split into partitions, and each partition is a separate ordered lane of messages [1]. The video's topic is `orders`, with three partitions and three copies of each. The create command follows the operations docs [6].

```bash
bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic orders --partitions 3 --replication-factor 3
```

```bash
bin/kafka-topics.sh --describe --topic orders --bootstrap-server localhost:9092
```

You should see one line per partition with its `Leader`, `Replicas` and `Isr`. In the video's run, partition 1 printed `Leader: 2 Replicas: 2,3,1 Isr: 2,3,1`.

## Send one order with a key

The order has the key `user-42`. Per the Kafka introduction, events with the same key are written to the same partition [1], and Kafka keeps the order of events inside one partition [1]. That is why all of one user's orders stay in order. The producer hashes the key to choose the partition; in the run, `user-42` landed in partition 1, and so did every other `user-42` order.

Only one broker takes writes for a partition. Per the design docs, each partition has a single leader, and all writes go to it [3]. For partition 1 that was broker 2.

## Find the offset the leader gave it

The leader appends the message to the end of the partition's log. Each slot in the log has a number, the offset. In the run, the order landed at offset 1447, right after a batch that ended at 1446. The log is an ordinary file on broker 2's disk, `/tmp/kafka-logs/orders-1/00000000000000000000.log` (35,199 bytes at that moment).

## Check the copies on the other brokers

One copy on one machine is not enough. Per the design docs, followers fetch from the leader the way a normal consumer does and apply the messages to their own log [3]. In the run, brokers 3 and 1 each held the order at the same offset, 1447.

The producer's OK depends on those copies. The default is `acks=all`: the leader waits for the full set of in-sync replicas before it answers [4]. The run's in-sync set for partition 1 was brokers 2, 3 and 1.

## Read it with a consumer group and check the commit

Consumers read in groups. The group in the video is called `billing`. After it reads offset 1447, it commits 1448: the committed offset is the next message the application will read [7]. Kafka stores that position as a message in an internal topic [3].

```bash
bin/kafka-console-consumer.sh --topic orders --group billing --from-beginning --bootstrap-server localhost:9092
```

```bash
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group billing
```

You should see a row for each partition with `CURRENT-OFFSET`, `LOG-END-OFFSET` and `LAG` [6]. In the run, partition 1 showed `CURRENT-OFFSET` 1448, `LOG-END-OFFSET` 1448 and `LAG` 0.

## Restart the reader and see where it resumes

Reading did not remove the order. It stays in the log until retention removes it, and the broker default `log.retention.hours` is 168, which is 7 days [5]. Another group can read the same message from its own offset [1].

When `billing` came back in the run, it resumed at its saved offset: the first record it read was offset 1448, the next order from `user-42`.

What happens to this order when broker 2 dies is in [part 2: when a Kafka OK means your message is saved](/blog/when-kafka-ok-means-saved).

Send this to the friend who uses Kafka at work but never traced where one message goes.

## Sources

1. [Apache Kafka 4.1 docs: Introduction](https://kafka.apache.org/41/getting-started/introduction/)
2. [Apache Kafka 4.1 docs: Quickstart](https://kafka.apache.org/41/getting-started/quickstart/)
3. [Apache Kafka 4.1 docs: Design (Replication, The Consumer)](https://kafka.apache.org/41/design/design/)
4. [Apache Kafka 4.1 docs: Producer configs (acks)](https://kafka.apache.org/41/configuration/producer-configs/)
5. [Apache Kafka 4.1 docs: Broker configs (log.retention.hours)](https://kafka.apache.org/41/configuration/broker-configs/)
6. [Apache Kafka 4.1 docs: Basic Kafka operations (consumer groups)](https://kafka.apache.org/41/operations/basic-kafka-operations/)
7. [Apache Kafka 4.1 Javadoc: KafkaConsumer (committed offset)](https://kafka.apache.org/41/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html)
