且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Spring Kafka:在运行时订阅新的主题模式

更新时间:2023-09-18 23:18:58

您将kafkaTopicPattern设置为-

You are getting kafkaTopicPattern as -

@Qualifier("kafkaTopicPattern")
private String kafkaTopicPattern;

我看到您正在更新--

this.kafkaTopicPattern = "new-topic-pattern";

但是,如果这两个实例位于不同的实例对象中,则不会刷新注入到侦听器中的"kafkaTopicPattern"的原始值.因此,您必须确保使用新的模式刷新侦听器对象.

But the original value for "kafkaTopicPattern" which is injected in listener wont be refreshed by this if these 2 are in different instance objects. So you will have to make sure that the listener objects are refreshed with the new pattern.