Skip to content

[ISSUE #11623] Support extension metadata in proxy heartbeat synchronization - #11624

Open
Allenhuangrui wants to merge 5 commits into
apache:developfrom
Allenhuangrui:codex/heartbeat-sync-ext-info
Open

Allenhuangrui wants to merge 5 commits into
apache:developfrom
Allenhuangrui:codex/heartbeat-sync-ext-info

Conversation

@Allenhuangrui

@Allenhuangrui Allenhuangrui commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Fixes #11623

Brief Description

Allow proxy integrations to propagate optional consumer metadata through heartbeat synchronization without duplicating the heartbeat sender/receiver or overloading protocol-specific channel data.

  • Add an optional Map<String, String> extInfo to HeartbeatSyncerData.
  • Add optional HeartbeatSendHandler and HeartbeatReceiveHandler callbacks, configurable through HeartbeatSyncer and ClusterConsumerManager. Both expose accept(String group, Map<String, String> extInfo, Channel channel); neither receives the mutable heartbeat DTO.
  • The sender receives the original group, a mutable copy of the extension map, and the original local channel for both registration and unregistration. Extensions are written back only if the callback returns successfully; an empty map remains absent from the payload.
  • The receiver receives the original group, extension metadata, and the actual cached or newly decoded RemoteChannel, exposed through the Channel interface, before consumer registration/unregistration. It can attach connection metadata without changing the heartbeat's group, client ID, or event type. Declaring both parameters as Channel leaves the runtime objects and channel reuse unchanged.
  • Callback exceptions are logged and the existing heartbeat operation continues. Existing constructors, behavior without callbacks, and messages without extensions remain supported. The core does not interpret extension keys.

How Did You Test This Change?

  • On 7069a165ac4576555a39fda4551e302a28d1d1d6, all 16 tests in HeartbeatSyncerDataTest, HeartbeatSyncerExtInfoTest, and HeartbeatSyncerTest passed in a remote Kubernetes test pod on Linux amd64 / JDK 21 using the available dependency classpath.
  • The three modified production classes and the tests compiled with javac --release 8. This focused run is not a clean full Maven build.
  • Coverage includes original local channel delivery for registration/unregistration, updated channel attributes, extension isolation, callback failures, missing extensions, receiver channel reuse, and unregister cleanup.
  • Checkstyle 9.3 passed for HeartbeatSyncer.java, the only file changed in the latest revision, using the repository configuration. git diff --check passed.
  • CI for this head has started and is not yet complete. The previous head's Bazel workflow had two failures outside the heartbeat path (LocalGrpcIT.testSimpleConsumerSendAndRecvPriorityMessage and OffsetResetForPopIT.testResetOffsetThenAckOldForPopOrderly); those tests were not changed. No full-CI success is claimed.

@codecov-commenter

codecov-commenter commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 51.37%. Comparing base (e114b54) to head (7069a16).
⚠️ Report is 13 commits behind head on develop.

Files with missing lines Patch % Lines
...etmq/proxy/service/sysmessage/HeartbeatSyncer.java 95.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11624      +/-   ##
=============================================
+ Coverage      50.86%   51.37%   +0.50%     
- Complexity     14881    15053     +172     
=============================================
  Files           1391     1391              
  Lines         103773   103969     +196     
  Branches       13614    13649      +35     
=============================================
+ Hits           52789    53409     +620     
+ Misses         44724    44297     -427     
- Partials        6260     6263       +3     

☔ View full report in Codecov by Harness.
📢 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.

channel = remoteChannelMap.getOrDefault(key, decodedChannel);
}
channel.setExtendAttribute(decodedChannel.getChannelExtendAttribute());
processHeartbeatData(data, channel);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The receive hook can change data.getGroup() after the remote channel cache key has been computed, and catching a hook exception does not undo that change. Could the hook receive only the extension metadata so the cache and consumer registration always use the same group?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hook currently receives the mutable heartbeat DTO after the cache key is computed, so changing the group can make the cache key and the consumer operation disagree; catching an exception does not restore it. I’ll narrow the receive hook to the original group string, extension metadata, and the resolved RemoteChannel, without exposing the DTO. The group is needed to scope the channel-attached integration metadata. I’ll also strengthen the regression tests for registration, unregistration, and hook failures. The wire format will remain unchanged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in f3c384d. Neither hook receives HeartbeatSyncerData now:

  • The send hook receives the original group and a mutable copy of extInfo. The copy is written back only after a successful callback, so partial extension updates are discarded on failure.
  • The receive hook receives the original group, extInfo, and the actual RemoteChannel used for registration/unregistration. Keeping the channel lets extensions attach connection metadata before consumer events run; the mutable heartbeat DTO stays private to the syncer.

Added regression coverage for extension keys resembling core fields, callback failures, channel reuse and cache cleanup, and empty extensions. The wire format is unchanged. Runtime verification is still pending because the remote test environment is unavailable; this revision has passed git diff --check.

@qianye1001 qianye1001 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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.

[Feature] Support extension metadata in proxy heartbeat synchronization

4 participants