多分片并发消费

This commit is contained in:
shikong 2024-07-07 18:47:38 +08:00
parent 346ffe3d23
commit aa7f659b23
Signed by: Shikong
GPG Key ID: BD85FF18B373C341

View File

@ -11,7 +11,7 @@ import org.springframework.stereotype.Component;
@Component @Component
public class MQListener { public class MQListener {
@KafkaListener(topics = {"test"},groupId = "test-group") @KafkaListener(topics = {"test"},groupId = "test-group", concurrency = "3")
public void onMessage(ConsumerRecord<String, String> record, Acknowledgment ack) { public void onMessage(ConsumerRecord<String, String> record, Acknowledgment ack) {
log.info("消费消息: 主题 {} 分片 {} ",record.topic(),record.partition()); log.info("消费消息: 主题 {} 分片 {} ",record.topic(),record.partition());
log.info("key {}, value {}",record.key(),record.value()); log.info("key {}, value {}",record.key(),record.value());