Apache Kafka is a distributed event streaming platform used to publish, store, and process continuous streams of data records in real time, at high throughput and scale.
An online retailer might use Kafka to capture every "item added to cart" event in real time, feeding both a live inventory system and a recommendation engine from the same stream of events.
// Spring Boot: publish an event and consume it (spring-kafka dependency)
@Service
public class CartEvents {
private final KafkaTemplate<String, String> kafkaTemplate;
public CartEvents(KafkaTemplate<String, String> kafkaTemplate) {
this.kafkaTemplate = kafkaTemplate;
}
public void itemAdded(String userId, String productId) {
// key = userId, so all events of one user stay in order on one partition
kafkaTemplate.send("cart-events", userId, "ADDED:" + productId);
}
}
@Component
public class InventoryListener {
@KafkaListener(topics = "cart-events", groupId = "inventory-service")
public void onEvent(String event) {
System.out.println("Inventory received " + event);
}
}
// application.properties
// spring.kafka.bootstrap-servers=localhost:9092A concise interview answer is
Apache Kafka is a distributed event streaming platform that lets applications publish and subscribe to continuous streams of data through durable, partitioned topics, and it's built to handle very high throughput with strong durability and horizontal scalability, which is why it's a common backbone for real-time data pipelines.
Last updated: 1 November 2026
Next question: What are some common use cases of Kafka?