Java Code Examples for org.apache.rocketmq.client.producer.DefaultMQProducer#viewMessage()
The following examples show how to use
org.apache.rocketmq.client.producer.DefaultMQProducer#viewMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BatchSendIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testBatchSend_ViewMessage() throws Exception { List<Message> messageList = new ArrayList<>(); int batchNum = 100; for (int i = 0; i < batchNum; i++) { messageList.add(new Message(topic, RandomUtils.getStringByUUID().getBytes())); } DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); for (int i = 0; i < 3; i++) { producer.viewMessage(offsetIds[random.nextInt(batchNum)]); } for (int i = 0; i < 3; i++) { producer.viewMessage(topic, msgIds[random.nextInt(batchNum)]); } }
Example 2
Source File: BatchSendIT.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Test public void testBatchSend_ViewMessage() throws Exception { List<Message> messageList = new ArrayList<>(); int batchNum = 100; for (int i = 0; i < batchNum; i++) { messageList.add(new Message(topic, RandomUtils.getStringByUUID().getBytes())); } DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); for (int i = 0; i < 3; i++) { producer.viewMessage(offsetIds[random.nextInt(batchNum)]); } for (int i = 0; i < 3; i++) { producer.viewMessage(topic, msgIds[random.nextInt(batchNum)]); } }
Example 3
Source File: BatchSendIT.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void testBatchSend_ViewMessage() throws Exception { List<Message> messageList = new ArrayList<>(); int batchNum = 100; for (int i = 0; i < batchNum; i++) { messageList.add(new Message(topic, RandomUtils.getStringByUUID().getBytes())); } DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); for (int i = 0; i < 3; i++) { producer.viewMessage(offsetIds[random.nextInt(batchNum)]); } for (int i = 0; i < 3; i++) { producer.viewMessage(topic, msgIds[random.nextInt(batchNum)]); } }
Example 4
Source File: BatchSendIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testBatchSend_ViewMessage() throws Exception { List<Message> messageList = new ArrayList<>(); int batchNum = 100; for (int i = 0; i < batchNum; i++) { messageList.add(new Message(topic, RandomUtils.getStringByUUID().getBytes())); } DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); for (int i = 0; i < 3; i++) { producer.viewMessage(offsetIds[random.nextInt(batchNum)]); } for (int i = 0; i < 3; i++) { producer.viewMessage(topic, msgIds[random.nextInt(batchNum)]); } }
Example 5
Source File: BatchSendIT.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
@Test public void testBatchSend_ViewMessage() throws Exception { List<Message> messageList = new ArrayList<>(); int batchNum = 100; for (int i = 0; i < batchNum; i++) { messageList.add(new Message(topic, RandomUtils.getStringByUUID().getBytes())); } DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); for (int i = 0; i < 3; i++) { producer.viewMessage(offsetIds[random.nextInt(batchNum)]); } for (int i = 0; i < 3; i++) { producer.viewMessage(topic, msgIds[random.nextInt(batchNum)]); } }
Example 6
Source File: BatchSendIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testBatchSend_ViewMessage() throws Exception { List<Message> messageList = new ArrayList<>(); int batchNum = 100; for (int i = 0; i < batchNum; i++) { messageList.add(new Message(topic, RandomUtils.getStringByUUID().getBytes())); } DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); for (int i = 0; i < 3; i++) { producer.viewMessage(offsetIds[random.nextInt(batchNum)]); } for (int i = 0; i < 3; i++) { producer.viewMessage(topic, msgIds[random.nextInt(batchNum)]); } }
Example 7
Source File: BatchSendIT.java From DDMQ with Apache License 2.0 | 4 votes |
@Test public void testBatchSend_CheckProperties() throws Exception { List<Message> messageList = new ArrayList<>(); Message message = new Message(); message.setTopic(topic); message.setKeys("keys123"); message.setTags("tags123"); message.setWaitStoreMsgOK(false); message.setBuyerId("buyerid123"); message.setFlag(123); message.setBody("body".getBytes()); messageList.add(message); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); Message messageByOffset = producer.viewMessage(offsetIds[0]); Message messageByMsgId = producer.viewMessage(topic, msgIds[0]); System.out.println(messageByOffset); System.out.println(messageByMsgId); Assert.assertEquals(message.getTopic(), messageByMsgId.getTopic()); Assert.assertEquals(message.getTopic(), messageByOffset.getTopic()); Assert.assertEquals(message.getKeys(), messageByOffset.getKeys()); Assert.assertEquals(message.getKeys(), messageByMsgId.getKeys()); Assert.assertEquals(message.getTags(), messageByOffset.getTags()); Assert.assertEquals(message.getTags(), messageByMsgId.getTags()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByOffset.isWaitStoreMsgOK()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByMsgId.isWaitStoreMsgOK()); Assert.assertEquals(message.getBuyerId(), messageByOffset.getBuyerId()); Assert.assertEquals(message.getBuyerId(), messageByMsgId.getBuyerId()); Assert.assertEquals(message.getFlag(), messageByOffset.getFlag()); Assert.assertEquals(message.getFlag(), messageByMsgId.getFlag()); }
Example 8
Source File: BatchSendIT.java From rocketmq-4.3.0 with Apache License 2.0 | 4 votes |
@Test public void testBatchSend_CheckProperties() throws Exception { List<Message> messageList = new ArrayList<>(); Message message = new Message(); message.setTopic(topic); message.setKeys("keys123"); message.setTags("tags123"); message.setWaitStoreMsgOK(false); message.setBuyerId("buyerid123"); message.setFlag(123); message.setBody("body".getBytes()); messageList.add(message); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); Message messageByOffset = producer.viewMessage(offsetIds[0]); Message messageByMsgId = producer.viewMessage(topic, msgIds[0]); System.out.println(messageByOffset); System.out.println(messageByMsgId); Assert.assertEquals(message.getTopic(), messageByMsgId.getTopic()); Assert.assertEquals(message.getTopic(), messageByOffset.getTopic()); Assert.assertEquals(message.getKeys(), messageByOffset.getKeys()); Assert.assertEquals(message.getKeys(), messageByMsgId.getKeys()); Assert.assertEquals(message.getTags(), messageByOffset.getTags()); Assert.assertEquals(message.getTags(), messageByMsgId.getTags()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByOffset.isWaitStoreMsgOK()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByMsgId.isWaitStoreMsgOK()); Assert.assertEquals(message.getBuyerId(), messageByOffset.getBuyerId()); Assert.assertEquals(message.getBuyerId(), messageByMsgId.getBuyerId()); Assert.assertEquals(message.getFlag(), messageByOffset.getFlag()); Assert.assertEquals(message.getFlag(), messageByMsgId.getFlag()); }
Example 9
Source File: BatchSendIT.java From rocketmq-read with Apache License 2.0 | 4 votes |
@Test public void testBatchSend_CheckProperties() throws Exception { List<Message> messageList = new ArrayList<>(); Message message = new Message(); message.setTopic(topic); message.setKeys("keys123"); message.setTags("tags123"); message.setWaitStoreMsgOK(false); message.setBuyerId("buyerid123"); message.setFlag(123); message.setBody("body".getBytes()); messageList.add(message); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); Message messageByOffset = producer.viewMessage(offsetIds[0]); Message messageByMsgId = producer.viewMessage(topic, msgIds[0]); System.out.println(messageByOffset); System.out.println(messageByMsgId); Assert.assertEquals(message.getTopic(), messageByMsgId.getTopic()); Assert.assertEquals(message.getTopic(), messageByOffset.getTopic()); Assert.assertEquals(message.getKeys(), messageByOffset.getKeys()); Assert.assertEquals(message.getKeys(), messageByMsgId.getKeys()); Assert.assertEquals(message.getTags(), messageByOffset.getTags()); Assert.assertEquals(message.getTags(), messageByMsgId.getTags()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByOffset.isWaitStoreMsgOK()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByMsgId.isWaitStoreMsgOK()); Assert.assertEquals(message.getBuyerId(), messageByOffset.getBuyerId()); Assert.assertEquals(message.getBuyerId(), messageByMsgId.getBuyerId()); Assert.assertEquals(message.getFlag(), messageByOffset.getFlag()); Assert.assertEquals(message.getFlag(), messageByMsgId.getFlag()); }
Example 10
Source File: BatchSendIT.java From DDMQ with Apache License 2.0 | 4 votes |
@Test public void testBatchSend_CheckProperties() throws Exception { List<Message> messageList = new ArrayList<>(); Message message = new Message(); message.setTopic(topic); message.setKeys("keys123"); message.setTags("tags123"); message.setWaitStoreMsgOK(false); message.setBuyerId("buyerid123"); message.setFlag(123); message.setBody("body".getBytes()); messageList.add(message); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); Message messageByOffset = producer.viewMessage(offsetIds[0]); Message messageByMsgId = producer.viewMessage(topic, msgIds[0]); System.out.println(messageByOffset); System.out.println(messageByMsgId); Assert.assertEquals(message.getTopic(), messageByMsgId.getTopic()); Assert.assertEquals(message.getTopic(), messageByOffset.getTopic()); Assert.assertEquals(message.getKeys(), messageByOffset.getKeys()); Assert.assertEquals(message.getKeys(), messageByMsgId.getKeys()); Assert.assertEquals(message.getTags(), messageByOffset.getTags()); Assert.assertEquals(message.getTags(), messageByMsgId.getTags()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByOffset.isWaitStoreMsgOK()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByMsgId.isWaitStoreMsgOK()); Assert.assertEquals(message.getBuyerId(), messageByOffset.getBuyerId()); Assert.assertEquals(message.getBuyerId(), messageByMsgId.getBuyerId()); Assert.assertEquals(message.getFlag(), messageByOffset.getFlag()); Assert.assertEquals(message.getFlag(), messageByMsgId.getFlag()); }
Example 11
Source File: BatchSendIT.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 4 votes |
@Test public void testBatchSend_CheckProperties() throws Exception { List<Message> messageList = new ArrayList<>(); Message message = new Message(); message.setTopic(topic); message.setKeys("keys123"); message.setTags("tags123"); message.setWaitStoreMsgOK(false); message.setBuyerId("buyerid123"); message.setFlag(123); message.setBody("body".getBytes()); messageList.add(message); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); Message messageByOffset = producer.viewMessage(offsetIds[0]); Message messageByMsgId = producer.viewMessage(topic, msgIds[0]); System.out.println(messageByOffset); System.out.println(messageByMsgId); Assert.assertEquals(message.getTopic(), messageByMsgId.getTopic()); Assert.assertEquals(message.getTopic(), messageByOffset.getTopic()); Assert.assertEquals(message.getKeys(), messageByOffset.getKeys()); Assert.assertEquals(message.getKeys(), messageByMsgId.getKeys()); Assert.assertEquals(message.getTags(), messageByOffset.getTags()); Assert.assertEquals(message.getTags(), messageByMsgId.getTags()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByOffset.isWaitStoreMsgOK()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByMsgId.isWaitStoreMsgOK()); Assert.assertEquals(message.getBuyerId(), messageByOffset.getBuyerId()); Assert.assertEquals(message.getBuyerId(), messageByMsgId.getBuyerId()); Assert.assertEquals(message.getFlag(), messageByOffset.getFlag()); Assert.assertEquals(message.getFlag(), messageByMsgId.getFlag()); }
Example 12
Source File: BatchSendIT.java From rocketmq with Apache License 2.0 | 4 votes |
@Test public void testBatchSend_CheckProperties() throws Exception { List<Message> messageList = new ArrayList<>(); Message message = new Message(); message.setTopic(topic); message.setKeys("keys123"); message.setTags("tags123"); message.setWaitStoreMsgOK(false); message.setBuyerId("buyerid123"); message.setFlag(123); message.setBody("body".getBytes()); messageList.add(message); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); SendResult sendResult = producer.send(messageList); Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus()); String[] offsetIds = sendResult.getOffsetMsgId().split(","); String[] msgIds = sendResult.getMsgId().split(","); Assert.assertEquals(messageList.size(), offsetIds.length); Assert.assertEquals(messageList.size(), msgIds.length); Thread.sleep(2000); Message messageByOffset = producer.viewMessage(offsetIds[0]); Message messageByMsgId = producer.viewMessage(topic, msgIds[0]); System.out.println(messageByOffset); System.out.println(messageByMsgId); Assert.assertEquals(message.getTopic(), messageByMsgId.getTopic()); Assert.assertEquals(message.getTopic(), messageByOffset.getTopic()); Assert.assertEquals(message.getKeys(), messageByOffset.getKeys()); Assert.assertEquals(message.getKeys(), messageByMsgId.getKeys()); Assert.assertEquals(message.getTags(), messageByOffset.getTags()); Assert.assertEquals(message.getTags(), messageByMsgId.getTags()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByOffset.isWaitStoreMsgOK()); Assert.assertEquals(message.isWaitStoreMsgOK(), messageByMsgId.isWaitStoreMsgOK()); Assert.assertEquals(message.getBuyerId(), messageByOffset.getBuyerId()); Assert.assertEquals(message.getBuyerId(), messageByMsgId.getBuyerId()); Assert.assertEquals(message.getFlag(), messageByOffset.getFlag()); Assert.assertEquals(message.getFlag(), messageByMsgId.getFlag()); }