org.apache.rocketmq.common.message.Message.setTopic()方法的使用及代码示例

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

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

Message.setTopic介绍

暂无

代码示例

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

private static Message buildMessage(final int messageSize, final String topic) throws UnsupportedEncodingException {
    Message msg = new Message();
    msg.setTopic(topic);

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < messageSize; i += 10) {
      sb.append("hello baby");
    }

    msg.setBody(sb.toString().getBytes(RemotingHelper.DEFAULT_CHARSET));

    return msg;
  }
}

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

private static Message buildMessage(final String topic, final int messageSize) throws UnsupportedEncodingException {
  Message msg = new Message();
  msg.setTopic(topic);
  StringBuilder sb = new StringBuilder();
  for (int i = 0; i < messageSize; i += 11) {
    sb.append("hello jodie");
  }
  msg.setBody(sb.toString().getBytes(MixAll.DEFAULT_CHARSET));
  return msg;
}

代码示例来源:origin: apache/rocketmq-externals

rocketmqMsg.setTopic(topic);
String messageType = destination.getMessageType();
Preconditions.checkState(!messageType.contains("||"),

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

public static org.apache.rocketmq.common.message.Message msgConvert(BytesMessage omsMessage) {
  org.apache.rocketmq.common.message.Message rmqMessage = new org.apache.rocketmq.common.message.Message();
  rmqMessage.setBody(omsMessage.getBody(byte[].class));
  KeyValue sysHeaders = omsMessage.sysHeaders();
  KeyValue userHeaders = omsMessage.userHeaders();
  //All destinations in RocketMQ use Topic
  rmqMessage.setTopic(sysHeaders.getString(BuiltinKeys.DESTINATION));
  if (sysHeaders.containsKey(BuiltinKeys.START_TIME)) {
    long deliverTime = sysHeaders.getLong(BuiltinKeys.START_TIME, 0);
    if (deliverTime > 0) {
      rmqMessage.putUserProperty(RocketMQConstants.START_DELIVER_TIME, String.valueOf(deliverTime));
    }
  }
  for (String key : userHeaders.keySet()) {
    MessageAccessor.putProperty(rmqMessage, key, userHeaders.getString(key));
  }
  //System headers has a high priority
  for (String key : sysHeaders.keySet()) {
    MessageAccessor.putProperty(rmqMessage, key, sysHeaders.getString(key));
  }
  return rmqMessage;
}

代码示例来源:origin: didi/DDMQ

private static Message buildMessage(final String topic, final int messageSize) throws UnsupportedEncodingException {
  Message msg = new Message();
  msg.setTopic(topic);
  StringBuilder sb = new StringBuilder();
  for (int i = 0; i < messageSize; i += 11) {
    sb.append("hello jodie");
  }
  msg.setBody(sb.toString().getBytes(MixAll.DEFAULT_CHARSET));
  return msg;
}

代码示例来源:origin: didi/DDMQ

private static Message buildMessage(final int messageSize) throws UnsupportedEncodingException {
    Message msg = new Message();
    msg.setTopic("BenchmarkTest");

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < messageSize; i += 10) {
      sb.append("hello baby");
    }

    msg.setBody(sb.toString().getBytes(RemotingHelper.DEFAULT_CHARSET));

    return msg;
  }
}

代码示例来源:origin: didi/DDMQ

private static Message buildMessage(final int messageSize, final String topic) throws UnsupportedEncodingException {
    Message msg = new Message();
    msg.setTopic(topic);

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < messageSize; i += 10) {
      sb.append("hello baby");
    }

    msg.setBody(sb.toString().getBytes(RemotingHelper.DEFAULT_CHARSET));

    return msg;
  }
}

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

List<Message> messageList = new ArrayList<>();
Message message = new Message();
message.setTopic(topic);
message.setKeys("keys123");
message.setTags("tags123");

代码示例来源:origin: didi/DDMQ

public static org.apache.rocketmq.common.message.Message msgConvert(BytesMessage omsMessage) {
  org.apache.rocketmq.common.message.Message rmqMessage = new org.apache.rocketmq.common.message.Message();
  rmqMessage.setBody(omsMessage.getBody());
  KeyValue headers = omsMessage.headers();
  KeyValue properties = omsMessage.properties();
  //All destinations in RocketMQ use Topic
  if (headers.containsKey(MessageHeader.TOPIC)) {
    rmqMessage.setTopic(headers.getString(MessageHeader.TOPIC));
    rmqMessage.putUserProperty(NonStandardKeys.MESSAGE_DESTINATION, "TOPIC");
  } else {
    rmqMessage.setTopic(headers.getString(MessageHeader.QUEUE));
    rmqMessage.putUserProperty(NonStandardKeys.MESSAGE_DESTINATION, "QUEUE");
  }
  for (String key : properties.keySet()) {
    MessageAccessor.putProperty(rmqMessage, key, properties.getString(key));
  }
  //Headers has a high priority
  for (String key : headers.keySet()) {
    MessageAccessor.putProperty(rmqMessage, key, headers.getString(key));
  }
  return rmqMessage;
}

代码示例来源:origin: jiangxinlingdu/rocketmq-all-4.1.0-incubating

private static Message buildMessage(final int messageSize) throws UnsupportedEncodingException {
    Message msg = new Message();
    msg.setTopic("BenchmarkTest");

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < messageSize; i += 10) {
      sb.append("hello baby");
    }

    msg.setBody(sb.toString().getBytes(RemotingHelper.DEFAULT_CHARSET));

    return msg;
  }
}

代码示例来源:origin: org.apache.rocketmq/rocketmq-tools

private static Message buildMessage(final String topic, final int messageSize) throws UnsupportedEncodingException {
  Message msg = new Message();
  msg.setTopic(topic);
  StringBuilder sb = new StringBuilder();
  for (int i = 0; i < messageSize; i += 11) {
    sb.append("hello jodie");
  }
  msg.setBody(sb.toString().getBytes(MixAll.DEFAULT_CHARSET));
  return msg;
}

代码示例来源:origin: didi/DDMQ

List<Message> messageList = new ArrayList<>();
Message message = new Message();
message.setTopic(topic);
message.setKeys("keys123");
message.setTags("tags123");

代码示例来源:origin: rstyro/Springboot

public void sendToMQ(Object object,String tags) throws Exception {
  //构造消息数据
  Message message = new Message();
  //主题
  message.setTopic(Const.PLAN_TOPIC);
  message.setTags(tags);
  //key
  String uuid = UUID.randomUUID().toString();
  message.setKeys(uuid);
  message.setBody(JSON.toJSONString(object).getBytes());
  //添加参数
  Map<String, Object> transactionMapArgs = new HashMap<String, Object>();
  this.planProducer.sendTransactionMessage(message, this.transactionExecuterImpl, transactionMapArgs);
}

代码示例来源:origin: org.apache.rocketmq/rocketmq-openmessaging

public static org.apache.rocketmq.common.message.Message msgConvert(BytesMessage omsMessage) {
  org.apache.rocketmq.common.message.Message rmqMessage = new org.apache.rocketmq.common.message.Message();
  rmqMessage.setBody(omsMessage.getBody(byte[].class));
  KeyValue sysHeaders = omsMessage.sysHeaders();
  KeyValue userHeaders = omsMessage.userHeaders();
  //All destinations in RocketMQ use Topic
  rmqMessage.setTopic(sysHeaders.getString(BuiltinKeys.DESTINATION));
  if (sysHeaders.containsKey(BuiltinKeys.START_TIME)) {
    long deliverTime = sysHeaders.getLong(BuiltinKeys.START_TIME, 0);
    if (deliverTime > 0) {
      rmqMessage.putUserProperty(RocketMQConstants.START_DELIVER_TIME, String.valueOf(deliverTime));
    }
  }
  for (String key : userHeaders.keySet()) {
    MessageAccessor.putProperty(rmqMessage, key, userHeaders.getString(key));
  }
  //System headers has a high priority
  for (String key : sysHeaders.keySet()) {
    MessageAccessor.putProperty(rmqMessage, key, sysHeaders.getString(key));
  }
  return rmqMessage;
}

相关文章