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

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

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

Message.getBody介绍

暂无

代码示例

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

private boolean tryToCompressMessage(final Message msg) {
  byte[] body = msg.getBody();
  if (body != null) {
    if (body.length >= this.defaultMQProducer.getCompressMsgBodyOverHowmuch()) {
      try {
        byte[] data = UtilAll.compress(body, zipCompressLevel);
        if (data != null) {
          msg.setBody(data);
          return true;
        }
      } catch (IOException e) {
        log.error("tryToCompressMessage exception", e);
        log.warn(msg.toString());
      }
    }
  }
  return false;
}

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

private boolean tryToCompressMessage(final Message msg) {
  byte[] body = msg.getBody();
  if (body != null) {
    if (body.length >= this.defaultMQProducer.getCompressMsgBodyOverHowmuch()) {
      try {
        byte[] data = UtilAll.compress(body, zipCompressLevel);
        if (data != null) {
          msg.setBody(data);
          return true;
        }
      } catch (IOException e) {
        log.error("tryToCompressMessage exception", e);
        log.warn(msg.toString());
      }
    }
  }
  return false;
}

代码示例来源:origin: beston123/Tarzan

public static void checkMessage(Message msg, DefaultMQProducer defaultMQProducer)
      throws MQClientException {
    if (null == msg) {
      throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message is null");
    }
    // topic
    Validators.checkTopic(msg.getTopic());
    // body
    if (null == msg.getBody()) {
      throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message body is null");
    }

    if (0 == msg.getBody().length) {
      throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message body length is zero");
    }

    if (defaultMQProducer != null && msg.getBody().length > defaultMQProducer.getMaxMessageSize()) {
      throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL,
          "the message body size over max value, MAX: " + defaultMQProducer.getMaxMessageSize());
    }
  }
}

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

/**
 * Validate message
 *
 * @param msg
 * @param defaultMQProducer
 *
 * @throws com.alibaba.rocketmq.client.exception.MQClientException
 */
public static void checkMessage(Message msg, DefaultMQProducer defaultMQProducer)
    throws MQClientException {
  if (null == msg) {
    throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message is null");
  }
  // topic
  Validators.checkTopic(msg.getTopic());
  // body
  if (null == msg.getBody()) {
    throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message body is null");
  }
  if (0 == msg.getBody().length) {
    throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message body length is zero");
  }
  if (msg.getBody().length > defaultMQProducer.getMaxMessageSize()) {
    throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL,
        "the message body size over max value, MAX: " + defaultMQProducer.getMaxMessageSize());
  }
}

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

/**
 * Validate message
 *
 * @param msg
 * @param defaultMQProducer
 *
 * @throws com.alibaba.rocketmq.client.exception.MQClientException
 */
public static void checkMessage(Message msg, DefaultMQProducer defaultMQProducer)
    throws MQClientException {
  if (null == msg) {
    throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message is null");
  }
  // topic
  Validators.checkTopic(msg.getTopic());
  // body
  if (null == msg.getBody()) {
    throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message body is null");
  }
  if (0 == msg.getBody().length) {
    throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message body length is zero");
  }
  if (msg.getBody().length > defaultMQProducer.getMaxMessageSize()) {
    throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL,
        "the message body size over max value, MAX: " + defaultMQProducer.getMaxMessageSize());
  }
}

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

request.setBody(msg.getBody());

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

request.setBody(msg.getBody());

代码示例来源:origin: songxinjianqwe/EShop-SOA

try {
  String paymentPassword = (String) arg;
  OrderDO order = ProtoStuffUtil.deserialize(msg.getBody(), OrderDO.class);
  if (order.getOrderStatus() != OrderStatus.UNPAID) {
    log.info("{} 订单状态不为unpaid", order.getId());
      .body(msg.getBody())
      .createTime(LocalDateTime.now())
      .updateTime(LocalDateTime.now())

代码示例来源:origin: beston123/Tarzan

private RocketMQBody buildMQBody(Message message){
  RocketMQBody mqBody = new RocketMQBody();
  mqBody.setProducerGroup(getGroupId());
  mqBody.setTopic(getTopic());
  mqBody.setTags(message.getTags());
  mqBody.setMessageKey(message.getKeys());
  mqBody.setMessageBody(message.getBody());
  return mqBody;
}

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

@Override
public void sendMessageBefore(SendMessageContext context) {
  // 如果是消息轨迹本身的发送链路,则不需要再记录
  if (context == null || context.getMessage().getTopic().startsWith(MixAll.SYSTEM_TOPIC_PREFIX)) {
    return;
  }
  OnsTraceContext onsContext = new OnsTraceContext();
  onsContext.setTraceBeans(new ArrayList<OnsTraceBean>(1));
  context.setMqTraceContext(onsContext);
  onsContext.setTraceType(OnsTraceType.Pub);
  onsContext.setGroupName(context.getProducerGroup());
  OnsTraceBean traceBean = new OnsTraceBean();
  traceBean.setTopic(context.getMessage().getTopic());
  traceBean.setTags(context.getMessage().getTags());
  traceBean.setKeys(context.getMessage().getKeys());
  traceBean.setStoreHost(context.getBrokerAddr());
  traceBean.setBodyLength(context.getMessage().getBody().length);
  traceBean.setMsgType(context.getMsgType());
  onsContext.getTraceBeans().add(traceBean);
}

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

brokerAddr = MixAll.brokerVIPChannel(this.defaultMQProducer.isSendMessageWithVIPChannel(), brokerAddr);
byte[] prevBody = msg.getBody();
try {

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

brokerAddr = MixAll.brokerVIPChannel(this.defaultMQProducer.isSendMessageWithVIPChannel(), brokerAddr);
byte[] prevBody = msg.getBody();
try {

相关文章