com.alibaba.rocketmq.broker.mqtrace.SendMessageHook Java Examples

The following examples show how to use com.alibaba.rocketmq.broker.mqtrace.SendMessageHook. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractSendMessageProcessor.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
public void executeSendMessageHookBefore(final ChannelHandlerContext ctx, final RemotingCommand request,
        SendMessageContext context) {
    if (hasSendMessageHook()) {
        for (SendMessageHook hook : this.sendMessageHookList) {
            try {
                final SendMessageRequestHeader requestHeader =
                        (SendMessageRequestHeader) request
                            .decodeCommandCustomHeader(SendMessageRequestHeader.class);
                context.setProducerGroup(requestHeader.getProducerGroup());
                context.setTopic(requestHeader.getTopic());
                context.setBodyLength(request.getBody().length);
                context.setMsgProps(requestHeader.getProperties());
                context.setBornHost(RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
                context.setBrokerAddr(this.brokerController.getBrokerAddr());
                context.setQueueId(requestHeader.getQueueId());
                hook.sendMessageBefore(context);
                requestHeader.setProperties(context.getMsgProps());
            }
            catch (Throwable e) {
            }
        }
    }
}
 
Example #2
Source File: AbstractSendMessageProcessor.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
public void executeSendMessageHookAfter(final RemotingCommand response, final SendMessageContext context) {
    if (hasSendMessageHook()) {
        for (SendMessageHook hook : this.sendMessageHookList) {
            try {
                if (response != null) {
                    final SendMessageResponseHeader responseHeader =
                            (SendMessageResponseHeader) response.readCustomHeader();
                    context.setMsgId(responseHeader.getMsgId());
                    context.setQueueId(responseHeader.getQueueId());
                    context.setQueueOffset(responseHeader.getQueueOffset());
                    context.setCode(response.getCode());
                    context.setErrorMsg(response.getRemark());
                }
                hook.sendMessageAfter(context);
            }
            catch (Throwable e) {

            }
        }
    }
}
 
Example #3
Source File: AbstractSendMessageProcessor.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public void executeSendMessageHookAfter(final RemotingCommand response, final SendMessageContext context) {
    if (hasSendMessageHook()) {
        for (SendMessageHook hook : this.sendMessageHookList) {
            try {
                if (response != null) {
                    final SendMessageResponseHeader responseHeader =
                            (SendMessageResponseHeader) response.readCustomHeader();
                    context.setMsgId(responseHeader.getMsgId());
                    context.setQueueId(responseHeader.getQueueId());
                    context.setQueueOffset(responseHeader.getQueueOffset());
                    context.setCode(response.getCode());
                    context.setErrorMsg(response.getRemark());
                }
                hook.sendMessageAfter(context);
            } catch (Throwable e) {

            }
        }
    }
}
 
Example #4
Source File: AbstractSendMessageProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public void executeSendMessageHookBefore(final ChannelHandlerContext ctx, final RemotingCommand request,
        SendMessageContext context) {
    if (hasSendMessageHook()) {
        for (SendMessageHook hook : this.sendMessageHookList) {
            try {
                final SendMessageRequestHeader requestHeader = (SendMessageRequestHeader) request
                    .decodeCommandCustomHeader(SendMessageRequestHeader.class);
                context.setProducerGroup(requestHeader.getProducerGroup());
                context.setTopic(requestHeader.getTopic());
                context.setBodyLength(request.getBody().length);
                context.setMsgProps(requestHeader.getProperties());
                context.setBornHost(RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
                context.setBrokerAddr(this.brokerController.getBrokerAddr());
                context.setQueueId(requestHeader.getQueueId());
                hook.sendMessageBefore(context);
                requestHeader.setProperties(context.getMsgProps());
            }
            catch (Throwable e) {
            }
        }
    }
}
 
Example #5
Source File: AbstractSendMessageProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public void executeSendMessageHookAfter(final RemotingCommand response,
        final SendMessageContext context) {
    if (hasSendMessageHook()) {
        for (SendMessageHook hook : this.sendMessageHookList) {
            try {
                if (response != null) {
                    final SendMessageResponseHeader responseHeader =
                            (SendMessageResponseHeader) response.readCustomHeader();
                    context.setMsgId(responseHeader.getMsgId());
                    context.setQueueId(responseHeader.getQueueId());
                    context.setQueueOffset(responseHeader.getQueueOffset());
                    context.setCode(response.getCode());
                    context.setErrorMsg(response.getRemark());
                }
                hook.sendMessageAfter(context);
            }
            catch (Throwable e) {

            }
        }
    }
}
 
Example #6
Source File: AbstractSendMessageProcessor.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public void executeSendMessageHookBefore(final ChannelHandlerContext ctx, final RemotingCommand request,
                                         SendMessageContext context) {
    if (hasSendMessageHook()) {
        for (SendMessageHook hook : this.sendMessageHookList) {
            try {
                final SendMessageRequestHeader requestHeader = parseRequestHeader(request);

                if (null != requestHeader) {
                    context.setProducerGroup(requestHeader.getProducerGroup());
                    context.setTopic(requestHeader.getTopic());
                    context.setBodyLength(request.getBody().length);
                    context.setMsgProps(requestHeader.getProperties());
                    context.setBornHost(RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
                    context.setBrokerAddr(this.brokerController.getBrokerAddr());
                    context.setQueueId(requestHeader.getQueueId());
                }

                hook.sendMessageBefore(context);

                if (null != requestHeader){
                    requestHeader.setProperties(context.getMsgProps());
                }else {
                    log.error("executeSendMessageHookBefore parse request error.");
                }
            } catch (Throwable e) {
            }
        }
    }
}
 
Example #7
Source File: BrokerController.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 4 votes vote down vote up
public void registerSendMessageHook(final SendMessageHook hook) {
    this.sendMessageHookList.add(hook);
    log.info("register SendMessageHook Hook, {}", hook.hookName());
}
 
Example #8
Source File: AbstractSendMessageProcessor.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 4 votes vote down vote up
public void registerSendMessageHook(List<SendMessageHook> sendMessageHookList) {
    this.sendMessageHookList = sendMessageHookList;
}
 
Example #9
Source File: SendMessageProcessor.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 4 votes vote down vote up
public void registerSendMessageHook(List<SendMessageHook> sendMessageHookList) {
    this.sendMessageHookList = sendMessageHookList;
}
 
Example #10
Source File: BrokerController.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public List<SendMessageHook> getSendMessageHookList() {
    return sendMessageHookList;
}
 
Example #11
Source File: BrokerController.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public void registerSendMessageHook(final SendMessageHook hook) {
    this.sendMessageHookList.add(hook);
    log.info("register SendMessageHook Hook, {}", hook.hookName());
}
 
Example #12
Source File: AbstractSendMessageProcessor.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public void registerSendMessageHook(List<SendMessageHook> sendMessageHookList) {
    this.sendMessageHookList = sendMessageHookList;
}
 
Example #13
Source File: BrokerController.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public void registerSendMessageHook(final SendMessageHook hook) {
    this.sendMessageHookList.add(hook);
    log.info("register SendMessageHook Hook, {}", hook.hookName());
}
 
Example #14
Source File: AbstractSendMessageProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public void registerSendMessageHook(List<SendMessageHook> sendMessageHookList) {
    this.sendMessageHookList = sendMessageHookList;
}
 
Example #15
Source File: SendMessageProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public void registerSendMessageHook(List<SendMessageHook> sendMessageHookList) {
    this.sendMessageHookList = sendMessageHookList;
}