com.alibaba.rocketmq.common.message.Message.setFlag()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(564)

本文整理了Java中com.alibaba.rocketmq.common.message.Message.setFlag()方法的一些代码示例,展示了Message.setFlag()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setFlag()方法的具体详情如下:
包路径:com.alibaba.rocketmq.common.message.Message
类名称:Message
方法名:setFlag

Message.setFlag介绍

暂无

代码示例

代码示例来源:origin: com.alibaba.rocketmq/rocketmq-client

  1. public boolean sendMessageBack(final MessageExt msg) {
  2. try {
  3. Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup()), msg.getBody());
  4. String originMsgId = MessageAccessor.getOriginMessageId(msg);
  5. MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
  6. newMsg.setFlag(msg.getFlag());
  7. MessageAccessor.setProperties(newMsg, msg.getProperties());
  8. MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
  9. MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes()));
  10. MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(this.defaultMQPushConsumer.getMaxReconsumeTimes()));
  11. newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
  12. this.defaultMQPushConsumer.getDefaultMQPushConsumerImpl().getmQClientFactory().getDefaultMQProducer().send(newMsg);
  13. return true;
  14. } catch (Exception e) {
  15. log.error("sendMessageBack exception, group: " + this.consumerGroup + " msg: " + msg.toString(), e);
  16. }
  17. return false;
  18. }

代码示例来源:origin: kuangye098/rocketmq

  1. public boolean sendMessageBack(final MessageExt msg) {
  2. try {
  3. Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup()), msg.getBody());
  4. String originMsgId = MessageAccessor.getOriginMessageId(msg);
  5. MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
  6. newMsg.setFlag(msg.getFlag());
  7. MessageAccessor.setProperties(newMsg, msg.getProperties());
  8. MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
  9. MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes()));
  10. MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(this.defaultMQPushConsumer.getMaxReconsumeTimes()));
  11. newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
  12. this.defaultMQPushConsumer.getDefaultMQPushConsumerImpl().getmQClientFactory().getDefaultMQProducer().send(newMsg);
  13. return true;
  14. } catch (Exception e) {
  15. log.error("sendMessageBack exception, group: " + this.consumerGroup + " msg: " + msg.toString(), e);
  16. }
  17. return false;
  18. }

代码示例来源:origin: com.alibaba.rocketmq/rocketmq-client

  1. public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName)
  2. throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
  3. try {
  4. String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
  5. : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
  6. this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg,
  7. this.defaultMQPushConsumer.getConsumerGroup(), delayLevel, 5000, this.defaultMQPushConsumer.getMaxReconsumeTimes());
  8. } catch (Exception e) {
  9. log.error("sendMessageBack Exception, " + this.defaultMQPushConsumer.getConsumerGroup(), e);
  10. Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup()), msg.getBody());
  11. String originMsgId = MessageAccessor.getOriginMessageId(msg);
  12. MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
  13. newMsg.setFlag(msg.getFlag());
  14. MessageAccessor.setProperties(newMsg, msg.getProperties());
  15. MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
  16. MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes() + 1));
  17. MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(this.defaultMQPushConsumer.getMaxReconsumeTimes()));
  18. newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
  19. this.mQClientFactory.getDefaultMQProducer().send(newMsg);
  20. }
  21. }

代码示例来源:origin: kuangye098/rocketmq

  1. public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName)
  2. throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
  3. try {
  4. String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
  5. : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
  6. this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg,
  7. this.defaultMQPushConsumer.getConsumerGroup(), delayLevel, 5000, this.defaultMQPushConsumer.getMaxReconsumeTimes());
  8. } catch (Exception e) {
  9. log.error("sendMessageBack Exception, " + this.defaultMQPushConsumer.getConsumerGroup(), e);
  10. Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup()), msg.getBody());
  11. String originMsgId = MessageAccessor.getOriginMessageId(msg);
  12. MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
  13. newMsg.setFlag(msg.getFlag());
  14. MessageAccessor.setProperties(newMsg, msg.getProperties());
  15. MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
  16. MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes() + 1));
  17. MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(this.defaultMQPushConsumer.getMaxReconsumeTimes()));
  18. newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
  19. this.mQClientFactory.getDefaultMQProducer().send(newMsg);
  20. }
  21. }

代码示例来源:origin: com.alibaba.rocketmq/rocketmq-client

  1. public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName, String consumerGroup)
  2. throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
  3. try {
  4. String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
  5. : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
  6. if (UtilAll.isBlank(consumerGroup)) {
  7. consumerGroup = this.defaultMQPullConsumer.getConsumerGroup();
  8. }
  9. this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg, consumerGroup, delayLevel, 3000,
  10. this.defaultMQPullConsumer.getMaxReconsumeTimes());
  11. } catch (Exception e) {
  12. log.error("sendMessageBack Exception, " + this.defaultMQPullConsumer.getConsumerGroup(), e);
  13. Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPullConsumer.getConsumerGroup()), msg.getBody());
  14. String originMsgId = MessageAccessor.getOriginMessageId(msg);
  15. MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
  16. newMsg.setFlag(msg.getFlag());
  17. MessageAccessor.setProperties(newMsg, msg.getProperties());
  18. MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
  19. MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes() + 1));
  20. MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(this.defaultMQPullConsumer.getMaxReconsumeTimes()));
  21. newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
  22. this.mQClientFactory.getDefaultMQProducer().send(newMsg);
  23. }
  24. }

代码示例来源:origin: kuangye098/rocketmq

  1. public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName, String consumerGroup)
  2. throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
  3. try {
  4. String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
  5. : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
  6. if (UtilAll.isBlank(consumerGroup)) {
  7. consumerGroup = this.defaultMQPullConsumer.getConsumerGroup();
  8. }
  9. this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg, consumerGroup, delayLevel, 3000,
  10. this.defaultMQPullConsumer.getMaxReconsumeTimes());
  11. } catch (Exception e) {
  12. log.error("sendMessageBack Exception, " + this.defaultMQPullConsumer.getConsumerGroup(), e);
  13. Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPullConsumer.getConsumerGroup()), msg.getBody());
  14. String originMsgId = MessageAccessor.getOriginMessageId(msg);
  15. MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
  16. newMsg.setFlag(msg.getFlag());
  17. MessageAccessor.setProperties(newMsg, msg.getProperties());
  18. MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
  19. MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes() + 1));
  20. MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(this.defaultMQPullConsumer.getMaxReconsumeTimes()));
  21. newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
  22. this.mQClientFactory.getDefaultMQProducer().send(newMsg);
  23. }
  24. }

代码示例来源:origin: coffeewar/enode-master

  1. public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName)
  2. throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
  3. try {
  4. String brokerAddr =
  5. (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
  6. : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
  7. this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg,
  8. this.defaultMQPushConsumer.getConsumerGroup(), delayLevel, 5000, this.defaultMQPushConsumer.getMaxReconsumeTimes());
  9. }
  10. catch (Exception e) {
  11. log.error("sendMessageBack Exception, " + this.defaultMQPushConsumer.getConsumerGroup(), e);
  12. Message newMsg =
  13. new Message(MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup()),
  14. msg.getBody());
  15. String originMsgId = MessageAccessor.getOriginMessageId(msg);
  16. MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId()
  17. : originMsgId);
  18. newMsg.setFlag(msg.getFlag());
  19. MessageAccessor.setProperties(newMsg, msg.getProperties());
  20. MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
  21. int reTimes = msg.getReconsumeTimes() + 1;
  22. MessageAccessor.setReconsumeTime(newMsg, reTimes + "");
  23. newMsg.setDelayTimeLevel(3 + reTimes);
  24. this.mQClientFactory.getDefaultMQProducer().send(newMsg);
  25. }
  26. }

相关文章