1 回答
TA贡献1794条经验 获得超7个赞
我刚刚复制了您的覆盖,一切都按预期进行。
@SpringBootApplication
public class So57674940Application {
public static void main(String[] args) {
SpringApplication.run(new Class<?>[] { So57674940Application.class, So57674940ApplicationConfig.class }, args);
}
@KafkaListener(id = "so57674940", topics = "so57674940")
public void listen(String in) {
System.out.println(in);
}
}
@Configuration
@EnableKafka
class So57674940ApplicationConfig {
@Bean(name = KafkaListenerConfigUtils.KAFKA_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME)
public KafkaListenerEndpointRegistry defaultKafkaListenerEndpointRegistry() {
return new KafkaListenerEndpointRegistry() {
@Override
public void registerListenerContainer(KafkaListenerEndpoint endpoint,
KafkaListenerContainerFactory<?> factory) {
// i need to add logic here
System.out.println("in custom registry");
super.registerListenerContainer(endpoint, factory);
}
};
}
}
和
in custom registry
2019-08-27 11:20:36.251 INFO 33460 --- [o57674940-0-C-1] o.s.k.l.KafkaMessageListenerContainer : partitions assigned: [so57674940-0]
添加回答
举报