@Test public void testSyncSendOrderly() throws ExecutionException, InterruptedException { for (int i = 0; i < 10; i++) { int id = 1; SendResult result = producer.syncSendOrderly(id); logger.info("[testSyncSend][发送编号：[{}] 发送队列：[{}]]", id, result.getRecordMetadata().partition()); } new CountDownLatch(1).await(); }
public SendResult syncSendOrderly(Integer id) throws ExecutionException, InterruptedException { Demo06Message message = new Demo06Message(); message.setId(id); return kafkaTemplate.send(Demo06Message.TOPIC, String.valueOf(id), message).get(); }
Demo06Producer { public SendResult syncSendOrderly(Integer id) throws ExecutionException, InterruptedException { Demo06Message message = new Demo06Message(); message.setId(id); return kafkaTemplate.send(Demo06Message.TOPIC, String.valueOf(id), message).get(); } }
Demo06Producer { public SendResult syncSendOrderly(Integer id) throws ExecutionException, InterruptedException { Demo06Message message = new Demo06Message(); message.setId(id); return kafkaTemplate.send(Demo06Message.TOPIC, String.valueOf(id), message).get(); }  }
Demo06Producer { public SendResult syncSendOrderly(Integer id) throws ExecutionException, InterruptedException { Demo06Message message = new Demo06Message(); message.setId(id); return kafkaTemplate.send(Demo06Message.TOPIC, String.valueOf(id), message).get(); }  SendResult syncSend(Integer id); SendResult syncSendOrderly(Integer id); }
Demo06Producer { public SendResult syncSendOrderly(Integer id) throws ExecutionException, InterruptedException { Demo06Message message = new Demo06Message(); message.setId(id); return kafkaTemplate.send(Demo06Message.TOPIC, String.valueOf(id), message).get(); }  SendResult syncSend(Integer id); SendResult syncSendOrderly(Integer id);  }