@Test public void testSyncSend() throws ExecutionException, InterruptedException { int id = (int) (System.currentTimeMillis() / 1000); SendResult result = producer.syncSend(id); logger.info("[testSyncSend][发送编号：[{}] 发送结果：[{}]]", id, result); new CountDownLatch(1).await(); }
public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo01Message message = new Demo01Message(); message.setId(id); return kafkaTemplate.send(Demo01Message.TOPIC, message).get(); }
Demo01Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo01Message message = new Demo01Message(); message.setId(id); return kafkaTemplate.send(Demo01Message.TOPIC, message).get(); } }
Demo01Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo01Message message = new Demo01Message(); message.setId(id); return kafkaTemplate.send(Demo01Message.TOPIC, message).get(); }  }
Demo01Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo01Message message = new Demo01Message(); message.setId(id); return kafkaTemplate.send(Demo01Message.TOPIC, message).get(); }  SendResult syncSend(Integer id); ListenableFuture<SendResult<Object, Object>> asyncSend(Integer id); }
Demo01Producer { public SendResult syncSend(Integer id) throws ExecutionException, InterruptedException { Demo01Message message = new Demo01Message(); message.setId(id); return kafkaTemplate.send(Demo01Message.TOPIC, message).get(); }  SendResult syncSend(Integer id); ListenableFuture<SendResult<Object, Object>> asyncSend(Integer id);  }