Back-End Development Message Queues and Event-Driven Architecture 1 — Questions and Answers
Question 1: What is a message queue primarily used for in back-end systems?
- Storing user session data
- Decoupling services and enabling asynchronous communication (Correct answer)
- Caching database query results
- Managing HTTP request routing
Correct answer: Decoupling services and enabling asynchronous communication
Message queues decouple producers and consumers, allowing services to communicate asynchronously without direct dependencies.
Question 2: In a publish-subscribe (pub/sub) pattern, what is a 'subscriber'?
- A service that writes messages to a queue
- A service that receives and processes messages from a topic (Correct answer)
- A load balancer that distributes messages
- A database that stores message metadata
Correct answer: A service that receives and processes messages from a topic
In pub/sub, subscribers listen to topics and receive every message published to those topics.
Question 3: What is the key difference between a point-to-point queue and a pub/sub topic?
- Queues are faster than topics
- A queue delivers each message to one consumer; a topic delivers to all subscribers (Correct answer)
- Topics require acknowledgment but queues do not
- Queues support only string messages while topics support binary
Correct answer: A queue delivers each message to one consumer; a topic delivers to all subscribers
In point-to-point queues each message is consumed by exactly one consumer, while topics broadcast messages to all active subscribers.
Question 4: What does a message acknowledgment (ACK) tell the broker in a queue system?
- The producer confirms the message was created successfully
- The consumer signals it has successfully processed the message (Correct answer)
- The broker confirms it has sufficient disk space
- The load balancer confirms message routing completed
Correct answer: The consumer signals it has successfully processed the message
An ACK tells the broker the consumer finished processing the message, allowing the broker to safely remove it from the queue.
Question 5: What is a Dead Letter Queue (DLQ) used for?
- Storing high-priority urgent messages
- Holding messages that failed processing after the maximum retry limit (Correct answer)
- Archiving all messages for compliance auditing
- Buffering messages during peak traffic spikes
Correct answer: Holding messages that failed processing after the maximum retry limit
A DLQ captures messages that could not be successfully processed after exhausting retries, enabling investigation and reprocessing.
Question 6: Which messaging pattern is best suited for distributing workload across multiple parallel workers?
- Publish/Subscribe
- Request/Reply
- Competing Consumers (Correct answer)
- Fan-out Exchange
Correct answer: Competing Consumers
The Competing Consumers pattern allows multiple consumers to pull from a single queue, distributing tasks and enabling horizontal scaling.
Question 7: What is the purpose of message durability in a message broker?
- Encrypting messages during transit
- Ensuring messages survive broker restarts by persisting them to disk (Correct answer)
- Compressing messages for efficient network transfer
- Routing messages to the consumer with the lowest latency
Correct answer: Ensuring messages survive broker restarts by persisting them to disk
Durable messages are written to disk so they are not lost if the broker crashes or is restarted.
What is a message queue primarily used for in back-end systems?