美文网首页
0009.使用环境变量中设定的topic

0009.使用环境变量中设定的topic

作者: 笑着字太黑 | 来源:发表于2022-05-25 11:46 被阅读0次

topics = {"#{__listener.getTopic()}"},
__listener相当于一个伪Bean,指向当前类

@Value("${KAFKA_TOPIC_XXXX}")
    private String topic;
    
@KafkaListener(
            id = "XXXXListener", 
            topics = {"#{__listener.getTopic()}"},
            properties = {"isolation.level:read_committed"}
        )
public void listen(ConsumerRecord<Integer, String> data) {
}
    public String getTopic() {
        return this.topic;
    }

相关文章

网友评论

      本文标题:0009.使用环境变量中设定的topic

      本文链接:https://www.haomeiwen.com/subject/eqyeprtx.html