use of org.apache.rocketmq.broker.mqtrace.SendMessageContext in project rocketmq by apache.
the class AbstractSendMessageProcessor method buildMsgContext.
protected SendMessageContext buildMsgContext(ChannelHandlerContext ctx, SendMessageRequestHeader requestHeader) {
if (!this.hasSendMessageHook()) {
return null;
}
SendMessageContext mqtraceContext;
mqtraceContext = new SendMessageContext();
mqtraceContext.setProducerGroup(requestHeader.getProducerGroup());
mqtraceContext.setTopic(requestHeader.getTopic());
mqtraceContext.setMsgProps(requestHeader.getProperties());
mqtraceContext.setBornHost(RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
mqtraceContext.setBrokerAddr(this.brokerController.getBrokerAddr());
mqtraceContext.setBrokerRegionId(this.brokerController.getBrokerConfig().getRegionId());
mqtraceContext.setBornTimeStamp(requestHeader.getBornTimestamp());
Map<String, String> properties = MessageDecoder.string2messageProperties(requestHeader.getProperties());
String uniqueKey = properties.get(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
properties.put(MessageConst.PROPERTY_MSG_REGION, this.brokerController.getBrokerConfig().getRegionId());
properties.put(MessageConst.PROPERTY_TRACE_SWITCH, String.valueOf(this.brokerController.getBrokerConfig().isTraceOn()));
requestHeader.setProperties(MessageDecoder.messageProperties2String(properties));
if (uniqueKey == null) {
uniqueKey = "";
}
mqtraceContext.setMsgUniqueKey(uniqueKey);
return mqtraceContext;
}
Aggregations