Implementation of Kafka.
MediumImagine you are building a simplified, in-memory version of Kafka. This system should allow Producers to publish messages to Topics, and Consumers to subscribe to those Topics and receive those messages. We are NOT building a distributed system here. The focus is on the core messaging and subscription mechanisms, emphasizing clean object-oriented design principles. We will leave out features like persistence, replication, and partitioning for simplicity.
Think of it this way: We need a "message bus" within a single JVM. This message bus must reliably deliver messages to all subscribed consumers. This reliability, in our simplified context, means ensuring that all active consumers receive each message exactly once (within the scope of a single JVM). This is a significantly simplified view of real-world Kafka, but a useful exercise for exploring design patterns.
Requirements
Interview Simulation
Experience a realistic interview conversation. The interviewer will ask clarifying questions,and you'll reveal your understanding of the requirements.
Let's start by understanding the scope. What are the core functionalities this system needs to provide?
💡 Interview Tip
Identify the Actors (Who uses the system?) and their Use Cases (What are they trying to achieve?). Start with the 'Happy Path' scenarios.