Skip to content

Instantly share code, notes, and snippets.

@mchmielarz
Created December 14, 2020 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mchmielarz/122a80a28f90cde825448b9a1f59454b to your computer and use it in GitHub Desktop.
Save mchmielarz/122a80a28f90cde825448b9a1f59454b to your computer and use it in GitHub Desktop.
@Component
public class PartitionedKafkaListenerConsumer {
@KafkaListener(
clientIdPrefix = "part0",
topics = "${spring.kafka.consumer.topic}",
groupId = "${spring.kafka.consumer.group-id}",
topicPartitions = {
@TopicPartition(topic = "${spring.kafka.consumer.topic}", partitions = {"0"})
})
public void partition0(ConsumerRecord<String, String> content) {
// processing logic comes here
}
@KafkaListener(
clientIdPrefix = "part1",
topics = "${spring.kafka.consumer.topic}", groupId = "${spring.kafka.consumer.group-id}",
topicPartitions = {
@TopicPartition(topic = "${spring.kafka.consumer.topic}", partitions = {"1"})
})
public void partition1(ConsumerRecord<String, String> content) {
// processing logic comes here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment