kafkaendpointlistenerregistry.start() throws null pointer exception

怎甘沉沦 提交于 2020-06-17 09:41:06

问题


I have a requirement where I want to start Kakfa consumer manually.

Code :

class    Dummy implements    
        ConsumerSeekAware
{

@Autowired     
KafkaListenerEndpointRegistry registry;

CountDownLatch latch;

@Autowired    
ConcurrentKafkaListenerContainerFactory     factory;

onIdleEvent(){
    latch.countdown()
}       
@KafkaListener(id="myContainer", 
   topics="mytopic",  
  autoStartup="false")    
public void listen() {}


@Scheduled(cron=" some time ")
    void do_some_consumption(){

latch = new CountDownLatch(1);    
this.registry.getListenerContainer("myContainer").start();    
    latch.await();
        do processing


   this.registry.getListenerContainer("myContainer").stop()

}
}

I have made the bean of ConcurrentKafkaListenerContainerFactory with all props in my other Config class which I am Autowiring here.

However, I get a null pointer exception when I start my container using this.registry.getListenerContainer("myContainer").start()

来源:https://stackoverflow.com/questions/62412316/kafkaendpointlistenerregistry-start-throws-null-pointer-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!