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

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

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

Message.getProperties介绍

暂无

代码示例

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

Message message = messages.get(nextIndex);
int tmpSize = message.getTopic().length() + message.getBody().length;
Map<String, String> properties = message.getProperties();
for (Map.Entry<String, String> entry : properties.entrySet()) {
  tmpSize += entry.getKey().length() + entry.getValue().length();

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

String properties = messageProperties2String(message.getProperties());
byte[] propertiesBytes = properties.getBytes(CHARSET_UTF8);

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

/**
 * Info,error,warn,callback method implementation
 */
public void append(LoggingEvent event) {
  if (null == producer) {
    return;
  }
  if (locationInfo) {
    event.getLocationInformation();
  }
  byte[] data = this.layout.format(event).getBytes();
  try {
    Message msg = new Message(topic, tag, data);
    msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOG4J_APPENDER);
    //Send message and do not wait for the ack from the message broker.
    producer.sendOneway(msg);
  } catch (Exception e) {
    String msg = new String(data);
    errorHandler.error("Could not send message in RocketmqLog4jAppender [" + name + "].Message is :" + msg, e,
      ErrorCode.GENERIC_FAILURE);
  }
}

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

/**
 * Info,error,warn,callback method implementation
 */
@Override
protected void append(ILoggingEvent event) {
  if (!isStarted()) {
    return;
  }
  String logStr = this.layout.doLayout(event);
  try {
    Message msg = new Message(topic, tag, logStr.getBytes());
    msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOGBACK_APPENDER);
    //Send message and do not wait for the ack from the message broker.
    producer.sendOneway(msg);
  } catch (Exception e) {
    addError("Could not send message in RocketmqLogbackAppender [" + name + "]. Message is : " + logStr, e);
  }
}

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

if (msg.getProperties() != null) {
  msg.getProperties().clear();

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

/**
 * Info,error,warn,callback method implementation
 */
public void append(LogEvent event) {
  if (null == producer) {
    return;
  }
  byte[] data = this.getLayout().toByteArray(event);
  try {
    Message msg = new Message(topic, tag, data);
    msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOG4J2_APPENDER);
    //Send message and do not wait for the ack from the message broker.
    producer.sendOneway(msg);
  } catch (Exception e) {
    ErrorHandler handler = this.getHandler();
    if (handler != null) {
      String msg = new String(data);
      handler.error("Could not send message in RocketmqLog4j2Appender [" + this.getName() + "].Message is : " + msg, e);
    }
  }
}

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

public static Message cloneMessage(final Message msg) {
  Message newMsg = new Message(msg.getTopic(), msg.getBody());
  newMsg.setFlag(msg.getFlag());
  newMsg.setProperties(msg.getProperties());
  return newMsg;
}

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

private MessageExtBrokerInner makeOpMessageInner(Message message, MessageQueue messageQueue) {
  MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
  msgInner.setTopic(message.getTopic());
  msgInner.setBody(message.getBody());
  msgInner.setQueueId(messageQueue.getQueueId());
  msgInner.setTags(message.getTags());
  msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(msgInner.getTags()));
  msgInner.setSysFlag(0);
  MessageAccessor.setProperties(msgInner, message.getProperties());
  msgInner.setPropertiesString(MessageDecoder.messageProperties2String(message.getProperties()));
  msgInner.setBornTimestamp(System.currentTimeMillis());
  msgInner.setBornHost(this.storeHost);
  msgInner.setStoreHost(this.storeHost);
  msgInner.setWaitStoreMsgOK(false);
  MessageClientIDSetter.setUniqID(msgInner);
  return msgInner;
}

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

requestHeader.setBornTimestamp(System.currentTimeMillis());
requestHeader.setFlag(msg.getFlag());
requestHeader.setProperties(MessageDecoder.messageProperties2String(msg.getProperties()));
requestHeader.setReconsumeTimes(0);
requestHeader.setUnitMode(this.isUnitMode());

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

Message message = messages.get(nextIndex);
int tmpSize = message.getTopic().length() + message.getBody().length;
Map<String, String> properties = message.getProperties();
for (Map.Entry<String, String> entry : properties.entrySet()) {
  tmpSize += entry.getKey().length() + entry.getValue().length();

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

String properties = messageProperties2String(message.getProperties());
byte[] propertiesBytes = properties.getBytes(CHARSET_UTF8);

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

/**
 * Info,error,warn,callback method implementation
 */
public void append(LoggingEvent event) {
  if (null == producer) {
    return;
  }
  if (locationInfo) {
    event.getLocationInformation();
  }
  byte[] data = this.layout.format(event).getBytes();
  try {
    Message msg = new Message(topic, tag, data);
    msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOG4J_APPENDER);
    //Send message and do not wait for the ack from the message broker.
    producer.sendOneway(msg);
  } catch (Exception e) {
    String msg = new String(data);
    errorHandler.error("Could not send message in RocketmqLog4jAppender [" + name + "].Message is :" + msg, e,
      ErrorCode.GENERIC_FAILURE);
  }
}

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

/**
 * Info,error,warn,callback method implementation
 */
@Override
protected void append(ILoggingEvent event) {
  if (!isStarted()) {
    return;
  }
  String logStr = this.layout.doLayout(event);
  try {
    Message msg = new Message(topic, tag, logStr.getBytes());
    msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOGBACK_APPENDER);
    //Send message and do not wait for the ack from the message broker.
    producer.sendOneway(msg);
  } catch (Exception e) {
    addError("Could not send message in RocketmqLogbackAppender [" + name + "]. Message is : " + logStr, e);
  }
}

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

if (msg.getProperties() != null) {
  msg.getProperties().clear();

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

/**
 * Info,error,warn,callback method implementation
 */
public void append(LogEvent event) {
  if (null == producer) {
    return;
  }
  byte[] data = this.getLayout().toByteArray(event);
  try {
    Message msg = new Message(topic, tag, data);
    msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOG4J2_APPENDER);
    //Send message and do not wait for the ack from the message broker.
    producer.sendOneway(msg);
  } catch (Exception e) {
    ErrorHandler handler = this.getHandler();
    if (handler != null) {
      String msg = new String(data);
      handler.error("Could not send message in RocketmqLog4j2Appender [" + this.getName() + "].Message is : " + msg, e);
    }
  }
}

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

private SendMessageRequestHeader getMessageRequestHeader(Message msg, MessageQueue mq) {
  SendMessageRequestHeader requestHeader = new SendMessageRequestHeader();
  requestHeader.setProducerGroup(producer.getProducerGroup());
  requestHeader.setTopic(msg.getTopic());
  requestHeader.setDefaultTopic(producer.getCreateTopicKey());
  requestHeader.setDefaultTopicQueueNums(producer.getDefaultTopicQueueNums());
  requestHeader.setQueueId(mq.getQueueId());
  requestHeader.setSysFlag(0);
  requestHeader.setBornTimestamp(System.currentTimeMillis());
  requestHeader.setFlag(msg.getFlag());
  requestHeader.setProperties(MessageDecoder.messageProperties2String(msg.getProperties()));
  requestHeader.setReconsumeTimes(0);
  requestHeader.setUnitMode(producer.isUnitMode());
  return requestHeader;
}

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

requestHeader.setBornTimestamp(System.currentTimeMillis());
requestHeader.setFlag(msg.getFlag());
requestHeader.setProperties(MessageDecoder.messageProperties2String(msg.getProperties()));
requestHeader.setReconsumeTimes(0);
requestHeader.setUnitMode(this.isUnitMode());

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

public static Message cloneMessage(final Message msg) {
  Message newMsg = new Message(msg.getTopic(), msg.getBody());
  newMsg.setFlag(msg.getFlag());
  newMsg.setProperties(msg.getProperties());
  return newMsg;
}

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

private MessageExtBrokerInner makeOpMessageInner(Message message, MessageQueue messageQueue) {
  MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
  msgInner.setTopic(message.getTopic());
  msgInner.setBody(message.getBody());
  msgInner.setQueueId(messageQueue.getQueueId());
  msgInner.setTags(message.getTags());
  msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(msgInner.getTags()));
  msgInner.setSysFlag(0);
  MessageAccessor.setProperties(msgInner, message.getProperties());
  msgInner.setPropertiesString(MessageDecoder.messageProperties2String(message.getProperties()));
  msgInner.setBornTimestamp(System.currentTimeMillis());
  msgInner.setBornHost(this.storeHost);
  msgInner.setStoreHost(this.storeHost);
  msgInner.setWaitStoreMsgOK(false);
  MessageClientIDSetter.setUniqID(msgInner);
  return msgInner;
}

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

public static org.springframework.messaging.Message convertToSpringMessage(
  org.apache.rocketmq.common.message.Message message) {
  org.springframework.messaging.Message retMessage =
    MessageBuilder.withPayload(message.getBody()).
      setHeader(RocketMQHeaders.KEYS, message.getKeys()).
      setHeader(RocketMQHeaders.TAGS, message.getTags()).
      setHeader(RocketMQHeaders.TOPIC, message.getTopic()).
      setHeader(RocketMQHeaders.FLAG, message.getFlag()).
      setHeader(RocketMQHeaders.TRANSACTION_ID, message.getTransactionId()).
      setHeader(RocketMQHeaders.PROPERTIES, message.getProperties()).
      build();
  return retMessage;
}

相关文章