Kafka: Two groups both get every message

Consumer groups are how you fan out to independent services from one topic.

Code
@KafkaListener(topics = "orders", groupId = "email-service")
void sendEmail(Order o) { ... }

@KafkaListener(topics = "orders", groupId = "analytics-service")
void record(Order o) { ... }
Output
One order produces one record.
Both services receive it, because each group tracks its own offsets.
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-11