-
Notifications
You must be signed in to change notification settings - Fork 11.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE #2556] Lite pull consumer support message trace #2598
[ISSUE #2556] Lite pull consumer support message trace #2598
Conversation
for (ConsumeMessageHook hook : this.consumeMessageHookList) { | ||
try { | ||
hook.consumeMessageBefore(context); | ||
} catch (Throwable e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swallowing exceptions is not a good practice
@@ -60,7 +60,6 @@ public void sendMessageBefore(SendMessageContext context) { | |||
traceBean.setStoreHost(context.getBrokerAddr()); | |||
traceBean.setBodyLength(context.getMessage().getBody().length); | |||
traceBean.setMsgType(context.getMsgType()); | |||
traceBean.setClientHost(((AsyncTraceDispatcher)localDispatcher).getHostProducer().getmQClientFactory().getClientId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this clienthost?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the trace message is a normal message, it has BornHost itself, this is the client IP, there is no need to add in the trace content.Simply to display the trace data, assign the BornHost of the message to the clientHost of the traceBean.
The BornHost of a pub Trace message is the IP of the client producer, and the BornHost of a sub Trace message is the IP of the client consumer.
AsyncTraceDispatcher dispatcher = new AsyncTraceDispatcher(consumerGroup, TraceDispatcher.Type.CONSUME, customizedTraceTopic, rpcHook); | ||
traceDispatcher = dispatcher; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, there are two points keys:
firstly, you can add this keywords, such as, this.traceDispatcher ;
secondly, the dispatcher object is redunctant, you can initial the object instance directly, such as, this.traceDispatcher = new AsyncTraceDispatcher(consumerGroup, TraceDispatcher.Type.CONSUME, customizedTraceTopic, rpcHook);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AsyncTraceDispatcher initialization code for this block is the same as for DefaultMQPushConsumer and DefaultMQProducer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay!
ConsumeMessageContext consumeMessageContext = null; | ||
consumeMessageContext = new ConsumeMessageContext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, why don't you initial the consumeMessageContext object instance directly?
This submission is in conflict with the PR submission of the previous #2833. I plan to close this PR and submit it again based on the current code.@duhenglucky @zongtanghu |
Make sure set the target branch to
develop
What is the purpose of the change
Lite pull consumer support message trace and optimize the clienthost in the message trace
Brief changelog
XX
Verifying this change
XXXX
Follow this checklist to help us incorporate your contribution quickly and easily. Notice,
it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR
.[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.