Back-End Development Message Queues and Event-Driven Architecture 2 — Questions and Answers
Question 1: How does Apache Kafka differ from traditional message queues?
- It only supports JSON-formatted messages
- It stores messages as an immutable, ordered log that consumers can replay (Correct answer)
- It requires all consumers to process messages synchronously
- It uses HTTP instead of TCP for message transport
Correct answer: It stores messages as an immutable, ordered log that consumers can replay
Kafka persists messages in an append-only log with configurable retention, allowing consumers to re-read or replay historical messages from any offset.
Question 2: In RabbitMQ, what is the role of an 'exchange'?
- A persistent storage layer for undelivered messages
- A routing component that receives messages and routes them to queues based on rules (Correct answer)
- A consumer group that load-balances incoming messages
- A protocol adapter between AMQP and HTTP
Correct answer: A routing component that receives messages and routes them to queues based on rules
An exchange receives messages from producers and routes them to one or more queues according to its type and binding rules.
Question 3: What is a Kafka consumer group?
- A set of producers writing to the same topic
- A collection of consumers that together consume all partitions of a topic (Correct answer)
- A cluster of Kafka brokers sharing storage
- An admin group for managing Kafka topic configurations
Correct answer: A collection of consumers that together consume all partitions of a topic
A consumer group distributes a topic's partitions among its members so that each partition is consumed by exactly one member, enabling parallel processing.
Question 4: What does 'at-least-once delivery' mean in a messaging system?
- A message is delivered exactly one time to exactly one consumer
- A message is delivered one or more times, potentially resulting in duplicates (Correct answer)
- A message is delivered only if the consumer is currently online
- A message is delivered to at least half of all registered consumers
Correct answer: A message is delivered one or more times, potentially resulting in duplicates
At-least-once delivery guarantees no messages are lost but may redeliver messages after failures, requiring consumers to handle duplicates.
Question 5: What is 'event sourcing' in back-end architecture?
- Logging only the final state of an entity after each change
- Storing all state changes as an ordered, immutable sequence of events (Correct answer)
- Generating synthetic test events for load and performance testing
- Pulling events from external third-party APIs into an internal system
Correct answer: Storing all state changes as an ordered, immutable sequence of events
Event sourcing persists every state change as an event so the current state can always be rebuilt by replaying the event log.
Question 6: In Apache Kafka, what is a 'partition'?
- A logical grouping of brokers for high availability
- An ordered, immutable sequence of messages within a topic (Correct answer)
- A consumer group boundary that isolates message processing
- A dedicated disk volume used for message persistence
Correct answer: An ordered, immutable sequence of messages within a topic
A Kafka partition is an ordered log segment of a topic that enables parallel reads and writes, providing the foundation for Kafka's scalability.
Question 7: What routing behavior does RabbitMQ's 'direct exchange' provide?
- It delivers messages to all bound queues simultaneously
- It routes messages to queues whose binding key exactly matches the message routing key (Correct answer)
- It uses message header attributes to make routing decisions
- It distributes messages evenly across all available queues in round-robin
Correct answer: It routes messages to queues whose binding key exactly matches the message routing key
A direct exchange routes a message to all queues whose binding key is an exact string match for the message's routing key.
How does Apache Kafka differ from traditional message queues?