Skip to content
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

Closed
wants to merge 4 commits into from
Closed

[ISSUE #2556] Lite pull consumer support message trace #2598

wants to merge 4 commits into from

Conversation

zhangjidi2016
Copy link
Contributor

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.

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 52.016% when pulling 61aa0e7 on zhangjidi2016:lite_pull_consumer_support_trace into 79ed2b6 on apache:develop.

@coveralls
Copy link

coveralls commented Jan 13, 2021

Coverage Status

Coverage increased (+0.1%) to 51.896% when pulling 90110e5 on zhangjidi2016:lite_pull_consumer_support_trace into 79ed2b6 on apache:develop.

@duhenglucky duhenglucky added this to the 4.8.1 milestone Jan 23, 2021
for (ConsumeMessageHook hook : this.consumeMessageHookList) {
try {
hook.consumeMessageBefore(context);
} catch (Throwable e) {
Copy link
Contributor

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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove this clienthost?

Copy link
Contributor Author

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.

Comment on lines +244 to +245
AsyncTraceDispatcher dispatcher = new AsyncTraceDispatcher(consumerGroup, TraceDispatcher.Type.CONSUME, customizedTraceTopic, rpcHook);
traceDispatcher = dispatcher;
Copy link
Contributor

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);

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay!

Comment on lines +883 to +884
ConsumeMessageContext consumeMessageContext = null;
consumeMessageContext = new ConsumeMessageContext();
Copy link
Contributor

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?

@duhenglucky duhenglucky self-requested a review May 6, 2021 02:23
@zhangjidi2016
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants