package com.qxueyou.scc.sys.msg; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Component; @Component public class CustomerMsgProducerService implements ICustomerMsgProducerService{ @Autowired KafkaTemplate template; public static String VIDEO_LIVE_TOPIC ="test.topic"; @Override public void doSendMediaVideoLiveMsg() { for(int i=0;;){ i++; template.setDefaultTopic(VIDEO_LIVE_TOPIC); template.sendDefault(String.valueOf(i), "foo"+i); try { Thread.sleep(10*1000); template.flush(); } catch (InterruptedException e) { } } // template.flush(); // container.stop(); } }