@Override public void sendOneway(final Message message) { checkMessageType(message); org.apache.rocketmq.common.message.Message rmqMessage = msgConvert((BytesMessage) message); try { this.rocketmqProducer.sendOneway(rmqMessage); } catch (Exception ignore) { //Ignore the oneway exception. } }
public void sendOneWay(Object msg, MessageQueueSelector selector, Object arg) { Message metaqMsg = (Message) msg; try { producer.sendOneway(metaqMsg, selector, arg); msgBodys.addData(new String(metaqMsg.getBody())); originMsgs.addData(msg); } catch (Exception e) { e.printStackTrace(); } }
public void sendOneWay(Object msg) { Message metaqMsg = (Message) msg; try { producer.sendOneway(metaqMsg); msgBodys.addData(new String(metaqMsg.getBody())); originMsgs.addData(msg); } catch (Exception e) { e.printStackTrace(); } }
public void sendOneWay(Object msg, MessageQueue mq) { Message metaqMsg = (Message) msg; try { producer.sendOneway(metaqMsg, mq); msgBodys.addData(new String(metaqMsg.getBody())); originMsgs.addData(msg); } catch (Exception e) { e.printStackTrace(); } }
@Test(expected = org.apache.rocketmq.client.exception.MQClientException.class) public void testSendSelectorNull() throws Exception { Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes()); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); MessageQueueSelector selector = null; producer.sendOneway(msg, selector, 100); }
@Test(expected = java.lang.NullPointerException.class) public void testSendMQNull() throws Exception { Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes()); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); MessageQueue messageQueue = null; producer.sendOneway(msg, messageQueue); }
@Test(expected = org.apache.rocketmq.client.exception.MQClientException.class) public void testSelectorThrowsException() throws Exception { Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes()); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); producer.sendOneway(msg, new MessageQueueSelector() { @Override public MessageQueue select(List<MessageQueue> list, Message message, Object o) { String str = null; return list.get(str.length()); } }, null); } }
/** * Same to {@link #sendOneWay(String, Message)} with send orderly with hashKey by specified. * * @param destination formats: `topicName:tags` * @param message {@link org.springframework.messaging.Message} * @param hashKey use this key to select queue. for example: orderId, productId ... */ public void sendOneWayOrderly(String destination, Message<?> message, String hashKey) { if (Objects.isNull(message) || Objects.isNull(message.getPayload())) { log.info("sendOneWayOrderly failed. destination:{}, message is null ", destination); throw new IllegalArgumentException("`message` and `message.payload` cannot be null"); } try { org.apache.rocketmq.common.message.Message rocketMsg = convertToRocketMsg(destination, message); producer.sendOneway(rocketMsg, messageQueueSelector, hashKey); } catch (Exception e) { log.info("sendOneWayOrderly failed. destination:{}, message:{}", destination, message); throw new MessagingException(e.getMessage(), e); } }
public void sendOneWay(Object msg) { Message metaqMsg = (Message) msg; try { producer.sendOneway(metaqMsg); msgBodys.addData(new String(metaqMsg.getBody())); originMsgs.addData(msg); } catch (Exception e) { e.printStackTrace(); } }
/** * Similar to <a href="https://en.wikipedia.org/wiki/User_Datagram_Protocol">UDP</a>, this method won't wait for * acknowledgement from broker before return. Obviously, it has maximums throughput yet potentials of message loss. * * One-way transmission is used for cases requiring moderate reliability, such as log collection. * * @param destination formats: `topicName:tags` * @param message {@link org.springframework.messaging.Message} */ public void sendOneWay(String destination, Message<?> message) { if (Objects.isNull(message) || Objects.isNull(message.getPayload())) { log.info("sendOneWay failed. destination:{}, message is null ", destination); throw new IllegalArgumentException("`message` and `message.payload` cannot be null"); } try { org.apache.rocketmq.common.message.Message rocketMsg = convertToRocketMsg(destination, message); producer.sendOneway(rocketMsg); } catch (Exception e) { log.info("sendOneWay failed. destination:{}, message:{} ", destination, message); throw new MessagingException(e.getMessage(), e); } }
public void sendOneWay(Object msg, MessageQueue mq) { Message metaqMsg = (Message) msg; try { producer.sendOneway(metaqMsg, mq); msgBodys.addData(new String(metaqMsg.getBody())); originMsgs.addData(msg); } catch (Exception e) { e.printStackTrace(); } }
public void sendOneWay(Object msg, MessageQueueSelector selector, Object arg) { Message metaqMsg = (Message) msg; try { producer.sendOneway(metaqMsg, selector, arg); msgBodys.addData(new String(metaqMsg.getBody())); originMsgs.addData(msg); } catch (Exception e) { e.printStackTrace(); } }
@Override public void sendOneway(final Message message) { checkMessageType(message); org.apache.rocketmq.common.message.Message rmqMessage = msgConvert((BytesMessage) message); try { this.rocketmqProducer.sendOneway(rmqMessage); } catch (Exception ignore) { //Ignore the oneway exception. } }
@Test(expected = java.lang.NullPointerException.class) public void testSendMQNull() throws Exception { Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes()); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); MessageQueue messageQueue = null; producer.sendOneway(msg, messageQueue); }
@Test(expected = org.apache.rocketmq.client.exception.MQClientException.class) public void testSendSelectorNull() throws Exception { Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes()); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); MessageQueueSelector selector = null; producer.sendOneway(msg, selector, 100); }
@Test(expected = org.apache.rocketmq.client.exception.MQClientException.class) public void testSelectorThrowsException() throws Exception { Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes()); DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr); producer.sendOneway(msg, new MessageQueueSelector() { @Override public MessageQueue select(List<MessageQueue> list, Message message, Object o) { String str = null; return list.get(str.length()); } }, null); } }
/** * Same to {@link #sendOneWay(String, Message)} with send orderly with hashKey by specified. * * @param destination formats: `topicName:tags` * @param message {@link org.springframework.messaging.Message} * @param hashKey use this key to select queue. for example: orderId, productId ... */ public void sendOneWayOrderly(String destination, Message<?> message, String hashKey) { if (Objects.isNull(message) || Objects.isNull(message.getPayload())) { log.error("sendOneWayOrderly failed. destination:{}, message is null ", destination); throw new IllegalArgumentException("`message` and `message.payload` cannot be null"); } try { org.apache.rocketmq.common.message.Message rocketMsg = RocketMQUtil.convertToRocketMessage(objectMapper, charset, destination, message); producer.sendOneway(rocketMsg, messageQueueSelector, hashKey); } catch (Exception e) { log.error("sendOneWayOrderly failed. destination:{}, message:{}", destination, message); throw new MessagingException(e.getMessage(), e); } }
/** * 发送Oneway消息 * * @param message 消息 * @return Result.true or false with exception */ public Result<SendResult> publishOneway(Message message) { try { producer.sendOneway(message); return new Result<SendResult>(true); } catch (Exception e) { logger.error(e.getMessage(), e); return new Result<SendResult>(false, e); } }
/** * Same to {@link #sendOneWay(String, Message)} with send orderly with hashKey by specified. * * @param destination formats: `topicName:tags` * @param message {@link org.springframework.messaging.Message} * @param hashKey use this key to select queue. for example: orderId, productId ... */ public void sendOneWayOrderly(String destination, Message<?> message, String hashKey) { if (Objects.isNull(message) || Objects.isNull(message.getPayload())) { log.info("sendOneWayOrderly failed. destination:{}, message is null ", destination); throw new IllegalArgumentException("`message` and `message.payload` cannot be null"); } try { org.apache.rocketmq.common.message.Message rocketMsg = convertToRocketMsg(destination, message); producer.sendOneway(rocketMsg, messageQueueSelector, hashKey); } catch (Exception e) { log.info("sendOneWayOrderly failed. destination:{}, message:{}", destination, message); throw new MessagingException(e.getMessage(), e); } }
@Override public void sendOneway(final Message message) { checkMessageType(message); org.apache.rocketmq.common.message.Message rmqMessage = msgConvert((BytesMessage) message); try { this.rocketmqProducer.sendOneway(rmqMessage); } catch (Exception ignore) { //Ignore the oneway exception. } }