Spring Boot2.0 整合 Kafka
在这里不再赘述,可参考Apache Kafka 安装步骤
@Test
public void kafkaSend() throws InterruptedException {
//模拟发消息
for (int i = 0; i < 5; i++) {
User user = new User();
user.setId(System.currentTimeMillis());
user.setMsg(UUID.randomUUID().toString());
user.setSendTime(new Date());
kafkaSender.send(user);
Thread.sleep(3000);
}
}