Skip to content

[ISSUE #1060] [Java] Enhance the logic of MessageInterceptor #1061

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

bcaw-ofeer
Copy link

Which Issue(s) This PR Fixes

Fixes #1060

Brief Description

Added MessageInterceptorContext information to provide more comprehensive information to the MessageInterceptor, including the remote address, messages sent by the producer, messages received, message type, consumption exceptions, and more.

@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2025

Codecov Report

❌ Patch coverage is 73.17073% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.11%. Comparing base (4076e2b) to head (40ac288).
⚠️ Report is 57 commits behind head on master.

Files with missing lines Patch % Lines
...e/rocketmq/client/java/rpc/LoggingInterceptor.java 25.00% 6 Missing ⚠️
...cketmq/client/java/impl/producer/ProducerImpl.java 80.00% 3 Missing ⚠️
...client/java/hook/CompositedMessageInterceptor.java 75.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1061      +/-   ##
============================================
- Coverage     53.26%   53.11%   -0.16%     
- Complexity      651      665      +14     
============================================
  Files           208      211       +3     
  Lines         14303    14039     -264     
  Branches       5845     5541     -304     
============================================
- Hits           7619     7457     -162     
+ Misses         6308     6206     -102     
  Partials        376      376              
Flag Coverage Δ
java 60.86% <73.17%> (-0.82%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -36,6 +38,11 @@ public class LoggingInterceptor implements ClientInterceptor {
private static final Logger log = LoggerFactory.getLogger(LoggingInterceptor.class);

private static final LoggingInterceptor INSTANCE = new LoggingInterceptor();
private static String remoteAddr = "";

public static String getRemoteAddr() {
Copy link
Member

Choose a reason for hiding this comment

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

static?

@@ -36,6 +38,11 @@ public class LoggingInterceptor implements ClientInterceptor {
private static final Logger log = LoggerFactory.getLogger(LoggingInterceptor.class);

private static final LoggingInterceptor INSTANCE = new LoggingInterceptor();
private static String remoteAddr = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

using static not support muti client instance

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ConsumeTask implements Callable<ConsumeResult> {
private static final Logger log = LoggerFactory.getLogger(ConsumeTask.class);

private static final String MESSAGE_VIEW_CONTEXT = "messageView";
Copy link
Contributor

Choose a reason for hiding this comment

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

AttributeKey

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.

5 participants