Skip to content

Instantly share code, notes, and snippets.

@mchmielarz
Created December 15, 2020 10:22
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/aea5327c74dde46b5eddf6b4e3d18417 to your computer and use it in GitHub Desktop.
Save mchmielarz/aea5327c74dde46b5eddf6b4e3d18417 to your computer and use it in GitHub Desktop.
@KafkaListener(groupId = "micronaut-group", clientId = "${kafka.consumers.micronaut-group.client-id}", threads = 5)
public class MultithreadedMicronautListener {
@Topic("${kafka.consumers.micronaut-group.topic}")
void receive(@KafkaKey String key, String value, int partition) {
switch (partition) {
case 0:
// processing logic comes here
break;
case 1:
// processing logic comes here
break;
case 2:
// processing logic comes here
break;
default:
log.error("Message (key {}, value {}) from unexpected partition ({}) received.", key, value, partition);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment