Search in sources :

Example 6 with SendMessageContext

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;
}
Also used : SendMessageContext(org.apache.rocketmq.broker.mqtrace.SendMessageContext)

Aggregations

SendMessageContext (org.apache.rocketmq.broker.mqtrace.SendMessageContext)6 ArrayList (java.util.ArrayList)2 SendMessageHook (org.apache.rocketmq.broker.mqtrace.SendMessageHook)2 SendMessageRequestHeader (org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader)2 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)2 AppendMessageResult (org.apache.rocketmq.store.AppendMessageResult)2 MessageExtBrokerInner (org.apache.rocketmq.store.MessageExtBrokerInner)2 PutMessageResult (org.apache.rocketmq.store.PutMessageResult)2 Test (org.junit.Test)2