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

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

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

Message.getTopic介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

for (int i = 0; i < mMessageList.size(); i++){
  Message mMessageModel = mMessageList.get(i);
  String My_Topic = mMessageModel.getTopic();
  // other stuff

}

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

private void checkMessage(Message message) throws MQClientException {
  if(message.getTopic() == null){
    message.setTopic(getTopic());
  }
  RocketMQValidators.checkMessage(message);
}

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

public SendResult send(Message msg, MessageQueue mq, long timeout)
    throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
  this.makeSureStateOK();
  Validators.checkMessage(msg, this.defaultMQProducer);
  if (!msg.getTopic().equals(mq.getTopic())) {
    throw new MQClientException("message's topic not equal mq's topic", null);
  }
  return this.sendKernelImpl(msg, mq, CommunicationMode.SYNC, null, null, timeout);
}

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

public SendResult send(Message msg, MessageQueue mq, long timeout)
    throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
  this.makeSureStateOK();
  Validators.checkMessage(msg, this.defaultMQProducer);
  if (!msg.getTopic().equals(mq.getTopic())) {
    throw new MQClientException("message's topic not equal mq's topic", null);
  }
  return this.sendKernelImpl(msg, mq, CommunicationMode.SYNC, null, null, timeout);
}

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

String.format("Connect broker failed, Topic: %s", message.getTopic()),
      FAQ.CONNECT_BROKER_FAILED));
  throw new RocketMQClientException(FAQ.errorMessage(String.format(
      "Send message to broker timeout, %dms, Topic: %s",
      this.defaultMQProducer.getSendMsgTimeout(), message.getTopic()),
      FAQ.SEND_MSG_TO_BROKER_TIMEOUT));
  MQBrokerException excep = (MQBrokerException) e.getCause();
  throw new RocketMQClientException(FAQ.errorMessage(
      String.format("Receive a broker exception, Topic: %s, %s", message.getTopic(),
          excep.getErrorMessage()), FAQ.BROKER_RESPONSE_EXCEPTION));
if (-1 == excep.getResponseCode()) {
  throw new RocketMQClientException(FAQ.errorMessage(
      String.format("Topic does not exist, Topic: %s, %s", message.getTopic(),
          excep.getErrorMessage()), FAQ.TOPIC_ROUTE_NOT_EXIST));
} else if (ResponseCode.MESSAGE_ILLEGAL == excep.getResponseCode()) {
  throw new RocketMQClientException(FAQ.errorMessage(String.format(
      "ONS Client check message exception, Topic: %s, %s", message.getTopic(),
      excep.getErrorMessage()), FAQ.CLIENT_CHECK_MSG_EXCEPTION));

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

public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
    throws MQClientException, RemotingException, InterruptedException {
  this.makeSureStateOK();
  Validators.checkMessage(msg, this.defaultMQProducer);
  if (!msg.getTopic().equals(mq.getTopic())) {
    throw new MQClientException("message's topic not equal mq's topic", null);
  }
  try {
    this.sendKernelImpl(msg, mq, CommunicationMode.ASYNC, sendCallback, null, timeout);
  } catch (MQBrokerException e) {
    throw new MQClientException("unknow exception", e);
  }
}

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

public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
    throws MQClientException, RemotingException, InterruptedException {
  this.makeSureStateOK();
  Validators.checkMessage(msg, this.defaultMQProducer);
  if (!msg.getTopic().equals(mq.getTopic())) {
    throw new MQClientException("message's topic not equal mq's topic", null);
  }
  try {
    this.sendKernelImpl(msg, mq, CommunicationMode.ASYNC, sendCallback, null, timeout);
  } catch (MQBrokerException e) {
    throw new MQClientException("unknow exception", e);
  }
}

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

private SendResult sendSelectImpl(//
                 Message msg, //
                 MessageQueueSelector selector, //
                 Object arg, //
                 final CommunicationMode communicationMode, //
                 final SendCallback sendCallback, final long timeout//
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
  this.makeSureStateOK();
  Validators.checkMessage(msg, this.defaultMQProducer);
  TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());
  if (topicPublishInfo != null && topicPublishInfo.ok()) {
    MessageQueue mq = null;
    try {
      mq = selector.select(topicPublishInfo.getMessageQueueList(), msg, arg);
    } catch (Throwable e) {
      throw new MQClientException("select message queue throwed exception.", e);
    }
    if (mq != null) {
      return this.sendKernelImpl(msg, mq, communicationMode, sendCallback, null, timeout);
    } else {
      throw new MQClientException("select message queue return null.", null);
    }
  }
  throw new MQClientException("No route info for this topic, " + msg.getTopic(), null);
}

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

private SendResult sendSelectImpl(//
                 Message msg, //
                 MessageQueueSelector selector, //
                 Object arg, //
                 final CommunicationMode communicationMode, //
                 final SendCallback sendCallback, final long timeout//
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
  this.makeSureStateOK();
  Validators.checkMessage(msg, this.defaultMQProducer);
  TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());
  if (topicPublishInfo != null && topicPublishInfo.ok()) {
    MessageQueue mq = null;
    try {
      mq = selector.select(topicPublishInfo.getMessageQueueList(), msg, arg);
    } catch (Throwable e) {
      throw new MQClientException("select message queue throwed exception.", e);
    }
    if (mq != null) {
      return this.sendKernelImpl(msg, mq, communicationMode, sendCallback, null, timeout);
    } else {
      throw new MQClientException("select message queue return null.", null);
    }
  }
  throw new MQClientException("No route info for this topic, " + msg.getTopic(), null);
}

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

long beginTimestampPrev = beginTimestampFirst;
long endTimestamp = beginTimestampFirst;
TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());
if (topicPublishInfo != null && topicPublishInfo.ok()) {
  MessageQueue mq = null;
      msg.getTopic(), //
      Arrays.toString(brokersSent));
throw new MQClientException("No route info of this topic, " + msg.getTopic() + FAQUrl.suggestTodo(FAQUrl.NO_TOPIC_ROUTE_INFO),
    null).setResponseCode(ClientErrorCode.NotFoundTopicException);

代码示例来源: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: songxinjianqwe/EShop-SOA

.updateTime(LocalDateTime.now())
.messageStatus(MessageStatus.UNCONSUMED)
.topic(msg.getTopic())
.sendTimes(0)
.build();

代码示例来源: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

(SendMessageResponseHeader) response.decodeCommandCustomHeader(SendMessageResponseHeader.class);
MessageQueue messageQueue = new MessageQueue(msg.getTopic(), brokerName, responseHeader.getQueueId());

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

@Override
public void sendMessageAfter(SendMessageContext context) {
  if (context == null || context.getMessage().getTopic().startsWith(OnsTraceConstants.traceTopic) || context.getMqTraceContext() == null) {
    return;

代码示例来源: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: kuangye098/rocketmq

(SendMessageResponseHeader) response.decodeCommandCustomHeader(SendMessageResponseHeader.class);
MessageQueue messageQueue = new MessageQueue(msg.getTopic(), brokerName, responseHeader.getQueueId());

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

MessageQueue tmpmq = producer.selectOneMessageQueue(topicPublishInfo, brokerName);
String addr = instance.findBrokerAddressInPublish(tmpmq.getBrokerName());
log.info("async send msg by retry {} times. topic={}, brokerAddr={}, brokerName={}", tmp, msg.getTopic(), addr,
    tmpmq.getBrokerName());
try {

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

MessageQueue tmpmq = producer.selectOneMessageQueue(topicPublishInfo, brokerName);
String addr = instance.findBrokerAddressInPublish(tmpmq.getBrokerName());
log.info("async send msg by retry {} times. topic={}, brokerAddr={}, brokerName={}", tmp, msg.getTopic(), addr,
    tmpmq.getBrokerName());
try {

相关文章