@Test public void testSyncSendX() throws ExecutionException, InterruptedException { for (int i = 0; i < 100; i++) { int id = (int) (System.currentTimeMillis() / 1000); SendResult result = producer.syncSend(id); logger.info("[testSyncSend][发送编号：[{}] 发送结果：[{}]]", id, result); Thread.sleep(10 * 1000L); } new CountDownLatch(1).await(); }
public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo04Message message = new Demo04Message(); message.setId(id); return kafkaTemplate.send(Demo04Message.TOPIC, message).get(); }
Demo04Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo04Message message = new Demo04Message(); message.setId(id); return kafkaTemplate.send(Demo04Message.TOPIC, message).get(); } }
Demo04Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo04Message message = new Demo04Message(); message.setId(id); return kafkaTemplate.send(Demo04Message.TOPIC, message).get(); }  }
Demo04Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo04Message message = new Demo04Message(); message.setId(id); return kafkaTemplate.send(Demo04Message.TOPIC, message).get(); }  SendResult syncSend(Integer id); }
Demo04Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo04Message message = new Demo04Message(); message.setId(id); return kafkaTemplate.send(Demo04Message.TOPIC, message).get(); }  SendResult syncSend(Integer id);  }