0
0
Kafkadevops~10 mins

Message broker architecture in Kafka - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Message broker architecture
Producer sends message
Message broker (Kafka)
Message stored in topic partition
Consumer reads message
Consumer processes message
This flow shows how a producer sends messages to Kafka, which stores them in topic partitions, and consumers read and process these messages.
Execution Sample
Kafka
producer.send('topic1', 'Hello Kafka')
# Kafka stores message
consumer.poll()
# Consumer reads message
A producer sends a message to a Kafka topic, Kafka stores it, and a consumer reads the message.
Process Table
StepActionComponentMessage StateOutput
1Producer sends message 'Hello Kafka' to 'topic1'ProducerMessage createdMessage sent to broker
2Broker receives messageKafka BrokerMessage stored in topic1 partitionAcknowledgement sent to producer
3Consumer polls 'topic1'ConsumerReads message from topic1 partitionMessage 'Hello Kafka' received
4Consumer processes messageConsumerMessage processedProcessing complete
5No more messagesConsumerNo new messagesPolling waits or ends
💡 No more messages in topic1, consumer polling ends or waits
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4Final
messageNone'Hello Kafka' created'Hello Kafka' stored in broker'Hello Kafka' read by consumer'Hello Kafka' processedProcessed
Key Moments - 2 Insights
Why does the consumer need to poll the broker to get messages?
Because Kafka stores messages in topics and consumers must request (poll) to receive new messages, as shown in step 3 of the execution_table.
What happens if the producer sends a message but the broker is down?
The message won't be stored and the producer won't get an acknowledgement, so the message is not confirmed as sent, unlike step 2 where the broker stores the message.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step does the message get stored in Kafka?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Check the 'Message State' column in step 2 where the message is stored in the topic partition.
According to variable_tracker, what is the state of 'message' after step 3?
A'Hello Kafka' read by consumer
BNone
C'Hello Kafka' processed
D'Hello Kafka' created
💡 Hint
Look at the 'After Step 3' column for 'message' in variable_tracker.
If the consumer never polls, what happens to the messages in Kafka?
AMessages are automatically deleted
BMessages are lost immediately
CMessages remain stored in the topic partition
DMessages are sent back to producer
💡 Hint
Kafka stores messages until consumers poll them, as shown in step 2 and 3.
Concept Snapshot
Message broker architecture in Kafka:
- Producers send messages to topics
- Kafka stores messages in partitions
- Consumers poll topics to read messages
- Messages remain until consumed or expired
- Broker acknowledges message receipt to producers
Full Transcript
This visual execution shows how a message flows in Kafka's message broker architecture. First, a producer creates and sends a message to a topic. The Kafka broker receives and stores the message in a topic partition, then acknowledges the producer. Consumers poll the broker to read messages from the topic. After reading, consumers process the messages. If no messages remain, polling waits or ends. Variables like 'message' change state from creation to processing. Key points include the need for consumers to poll to receive messages and the broker's role in storing messages reliably.