且构网

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

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

更新时间:2023-09-18 23:36:34

您将 kafkaTopicPattern 作为 -

You are getting kafkaTopicPattern as -

@Qualifier("kafkaTopicPattern")
private String kafkaTopicPattern;

我看到你正在更新模式 -

I see you are updating the pattern like -

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.