@Test public void testSendBatch() throws InterruptedException { List<Integer> ids = Arrays.asList(1, 2, 3); SendResult result = producer.sendBatch(ids); logger.info("[testSendBatch][发送编号：[{}] 发送结果：[{}]]", ids, result); new CountDownLatch(1).await(); }
public SendResult sendBatch(Collection<Integer> ids) { List<Message> messages = new ArrayList<>(ids.size()); for (Integer id : ids) { Demo02Message message = new Demo02Message().setId(id); messages.add(MessageBuilder.withPayload(message).build()); } return rocketMQTemplate.syncSend(Demo02Message.TOPIC, messages, 30 * 1000L); }
Demo02Producer { public SendResult sendBatch(Collection<Integer> ids) { List<Message> messages = new ArrayList<>(ids.size()); for (Integer id : ids) { Demo02Message message = new Demo02Message().setId(id); messages.add(MessageBuilder.withPayload(message).build()); } return rocketMQTemplate.syncSend(Demo02Message.TOPIC, messages, 30 * 1000L); } }
Demo02Producer { public SendResult sendBatch(Collection<Integer> ids) { List<Message> messages = new ArrayList<>(ids.size()); for (Integer id : ids) { Demo02Message message = new Demo02Message().setId(id); messages.add(MessageBuilder.withPayload(message).build()); } return rocketMQTemplate.syncSend(Demo02Message.TOPIC, messages, 30 * 1000L); }  }
Demo02Producer { public SendResult sendBatch(Collection<Integer> ids) { List<Message> messages = new ArrayList<>(ids.size()); for (Integer id : ids) { Demo02Message message = new Demo02Message().setId(id); messages.add(MessageBuilder.withPayload(message).build()); } return rocketMQTemplate.syncSend(Demo02Message.TOPIC, messages, 30 * 1000L); }  SendResult sendBatch(Collection<Integer> ids); }
Demo02Producer { public SendResult sendBatch(Collection<Integer> ids) { List<Message> messages = new ArrayList<>(ids.size()); for (Integer id : ids) { Demo02Message message = new Demo02Message().setId(id); messages.add(MessageBuilder.withPayload(message).build()); } return rocketMQTemplate.syncSend(Demo02Message.TOPIC, messages, 30 * 1000L); }  SendResult sendBatch(Collection<Integer> ids);  }