@KafkaListener 注解配置多个 topic

见如下示例

主要见 @KafkaListenertopics 属性的配置
其中 ${xxxx.topic1} 为从springBoot 配置文件中读取的属性值

    @KafkaListener(topics = {
   "${xxxx.topic1}", "${xxxx.topic2}"}, groupId = "${xxxx.groupId}",
            containerFactory = "xxxKafkaFactory")
    public void xxxXXX(ConsumerRecord<String, String> record, Acknowledgment ack,
                        @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) {
   
        // ..........
    }

理由

由于该注解 topic 为字符串数组的类型,所以可以如上加大括号来完成指定
在这里插入图片描述

相关推荐

  1. flink sinktopic

    2023-12-19 16:42:04       49 阅读
  2. 关于@KafkaListener动态订阅消费topic的调研

    2023-12-19 16:42:04       56 阅读
  3. Spring Boot中@KafkaListener使用${}动态指定topic

    2023-12-19 16:42:04       164 阅读
  4. Kafka的@KafkaListener注解参数详解

    2023-12-19 16:42:04       50 阅读
  5. Spring Kafka 之 @KafkaListener 注解详解

    2023-12-19 16:42:04       29 阅读
  6. nginx配置服务

    2023-12-19 16:42:04       189 阅读
  7. nginx配置前端)

    2023-12-19 16:42:04       31 阅读
  8. nginx 配置服务

    2023-12-19 16:42:04       23 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-19 16:42:04       91 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-19 16:42:04       97 阅读
  3. 在Django里面运行非项目文件

    2023-12-19 16:42:04       78 阅读
  4. Python语言-面向对象

    2023-12-19 16:42:04       88 阅读

热门阅读

  1. Linux 硬链接和软链接

    2023-12-19 16:42:04       70 阅读
  2. 【Spring】Spring AOP

    2023-12-19 16:42:04       44 阅读
  3. 计时器plus

    2023-12-19 16:42:04       57 阅读
  4. el-table表格中数据过长如何使用省略号

    2023-12-19 16:42:04       68 阅读
  5. CDN的特点及意义?

    2023-12-19 16:42:04       58 阅读
  6. kafka设置消费者组

    2023-12-19 16:42:04       66 阅读
  7. Ajax知识点大全

    2023-12-19 16:42:04       61 阅读
  8. [leetcode,动态规划] 完全平方数

    2023-12-19 16:42:04       49 阅读