@Test public void testSyncSend() throws ExecutionException, InterruptedException { for (int id = 1; id <= 2; id++) { SendResult result = producer.syncSend(id); logger.info("[testSyncSend][发送编号：[{}] 发送结果：[{}]]", id, result); } new CountDownLatch(1).await(); }
public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo08Message message = new Demo08Message(); message.setId(id); return kafkaTemplate.send(Demo08Message.TOPIC, message).get(); }
Demo08Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo08Message message = new Demo08Message(); message.setId(id); return kafkaTemplate.send(Demo08Message.TOPIC, message).get(); } }
Demo08Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo08Message message = new Demo08Message(); message.setId(id); return kafkaTemplate.send(Demo08Message.TOPIC, message).get(); }  }
Demo08Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo08Message message = new Demo08Message(); message.setId(id); return kafkaTemplate.send(Demo08Message.TOPIC, message).get(); }  SendResult syncSend(Integer id); }
Demo08Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo08Message message = new Demo08Message(); message.setId(id); return kafkaTemplate.send(Demo08Message.TOPIC, message).get(); }  SendResult syncSend(Integer id);  }