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

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

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

Message.putUserProperty介绍

暂无

代码示例

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

public static void main(String[] args) throws MQClientException, InterruptedException {
    DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
    producer.start();

    try {
      for (int i = 0; i < 6000000; i++) {
        Message msg = new Message("TopicFilter7",// topic
            "TagA",// tag
            "OrderID001",// key
            ("Hello MetaQ").getBytes(RemotingHelper.DEFAULT_CHARSET));// body

        msg.putUserProperty("SequenceId", String.valueOf(i));

        SendResult sendResult = producer.send(msg);
        System.out.println(sendResult);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    producer.shutdown();
  }
}

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

private Message createEQueueMessage(IApplicationMessage message) {
    TopicTagData topicTagData = _messageTopicProvider.getPublishTopic(message);
    String appMessageData = _jsonSerializer.serialize(message);
    ApplicationDataMessage appDataMessage = new ApplicationDataMessage(appMessageData, message.getClass().getName());

    String data = _jsonSerializer.serialize(appDataMessage);

    Message mqMessage =  new Message(topicTagData.getTopic(), //topic
        //_typeNameProvider.getTypeName(message.getClass()), //tags
        topicTagData.getTag(), //tag
        message.id(), // keys
        RocketMQMessageTypeCode.ApplicationMessage.getValue(), // flag
        BitConverter.getBytes(data), // body
        true);

    if (message.getStartDeliverTime() > 0) {
      mqMessage.putUserProperty(CommandService.RocketMQSystemPropKey.STARTDELIVERTIME, String.valueOf(message.getStartDeliverTime()));
    }

    return mqMessage;
  }
}

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

private Message buildCommandMessage(ICommand command, boolean needReply) {
    Ensure.notNull(command.getAggregateRootId(), "aggregateRootId");
    String commandData = _jsonSerializer.serialize(command);
    TopicTagData topicTagData = _commandTopicProvider.getPublishTopic(command);
    String replyAddress = needReply && _commandResultProcessor != null ? parseAddress(_commandResultProcessor.getBindingAddress()) : null;
//        String replyAddress = null;
    String messageData = _jsonSerializer.serialize(new CommandMessage(commandData, replyAddress, command.getClass().getName()));

    byte[] body = BitConverter.getBytes(messageData);

    String key = buildRocketMQMessageKey(command);

    Message message = new Message(topicTagData.getTopic(),
        topicTagData.getTag(),
        key,
        RocketMQMessageTypeCode.CommandMessage.ordinal(), body, true);

    if (command.getStartDeliverTime() > 0) {
      message.putUserProperty(RocketMQSystemPropKey.STARTDELIVERTIME, String.valueOf(command.getStartDeliverTime()));
    }

    return message;
  }

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

/**
 * 发送消息到MQ
 * @param mqMessage
 * @return
 */
private SendResult sendToMQ(RocketMQMessage mqMessage){
  /*************** 1、查找 MQ发送者 ***************/
  MQProducer producer;
  try {
    producer = getMQProducer(mqMessage.getProducerGroup());
  } catch (MQClientException e) {
    throw new SystemException("Get RocketMQ producer failed, group {}" + mqMessage.getProducerGroup(), e);
  }
  /*************** 2、组装并发送消息 ***************/
  Message msg = new Message(mqMessage.getTopic(), mqMessage.getTags(),
      mqMessage.getMessageKey(), mqMessage.getMessageBody());
  if(mqMessage.getId() != null){
    msg.putUserProperty(Constants.TARZAN_MQ_TID, String.valueOf(mqMessage.getId()));
  }
  try {
    return producer.send(msg);
  } catch (Exception e) {
    throw new SystemException("Send to RocketMQ failed, nameSrvAddress "+this.nameSrvAddr, e);
  }
}

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

try {
  if (sendResult.getTransactionId() != null) {
    msg.putUserProperty("__transactionId__", sendResult.getTransactionId());

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

try {
  if (sendResult.getTransactionId() != null) {
    msg.putUserProperty("__transactionId__", sendResult.getTransactionId());

相关文章