You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/08/03 13:38:04 UTC
[PR] [ISSUE #10793] Handle offline consumer list queries [rocketmq]
Aias00 opened a new pull request, #10794:
URL: https://github.com/apache/rocketmq/pull/10794
### Summary
- make `GET_CONSUMER_LIST_BY_GROUP` return `CONSUMER_NOT_ONLINE` when the requested group has no online consumer info
- align its behavior with `GET_CONSUMER_CONNECTION_LIST` in the same activity
- add coverage for the offline-group path
### Tests
- `mvn -pl proxy -Dtest=ConsumerManagerActivityTest test`
Closes #10793
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE #10793] Handle offline consumer list queries [rocketmq]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #10794:
URL: https://github.com/apache/rocketmq/pull/10794#discussion_r3704530950
##########
proxy/src/main/java/org/apache/rocketmq/proxy/remoting/activity/ConsumerManagerActivity.java:
##########
@@ -84,6 +84,11 @@ protected RemotingCommand getConsumerListByGroup(ChannelHandlerContext ctx, Remo
RemotingCommand response = RemotingCommand.createResponseCommand(GetConsumerListByGroupResponseHeader.class);
GetConsumerListByGroupRequestHeader header = (GetConsumerListByGroupRequestHeader) request.decodeCommandCustomHeader(GetConsumerListByGroupRequestHeader.class);
ConsumerGroupInfo consumerGroupInfo = messagingProcessor.getConsumerGroupInfo(context, header.getConsumerGroup());
+ if (consumerGroupInfo == null) {
+ response.setCode(ResponseCode.CONSUMER_NOT_ONLINE);
+ response.setRemark("the consumer group[" + header.getConsumerGroup() + "] not online");
+ return response;
+ }
Review Comment:
The not-online remark string is constructed inline via concatenation. If this message is also used in `GET_CONSUMER_CONNECTION_LIST` (per the PR description), consider extracting a shared helper/constant (or reusing an existing one) to keep message wording consistent across request codes and avoid future drift.
##########
proxy/src/test/java/org/apache/rocketmq/proxy/remoting/activity/ConsumerManagerActivityTest.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.proxy.remoting.activity;
+
+import org.apache.rocketmq.proxy.common.ProxyContext;
+import org.apache.rocketmq.proxy.config.InitConfigTest;
+import org.apache.rocketmq.proxy.processor.MessagingProcessor;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.remoting.protocol.RequestCode;
+import org.apache.rocketmq.remoting.protocol.ResponseCode;
+import org.apache.rocketmq.remoting.protocol.header.GetConsumerListByGroupRequestHeader;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ConsumerManagerActivityTest extends InitConfigTest {
+ private static final String CONSUMER_GROUP = "offline-group";
+
+ private ConsumerManagerActivity consumerManagerActivity;
+
+ @Mock
+ private MessagingProcessor messagingProcessor;
+
+ @Before
+ public void setup() {
+ this.consumerManagerActivity = new ConsumerManagerActivity(null, messagingProcessor);
+ }
+
+ @Test
+ public void testGetConsumerListByGroupShouldReturnNotOnlineWhenGroupMissing() throws Exception {
+ GetConsumerListByGroupRequestHeader header = new GetConsumerListByGroupRequestHeader();
+ header.setConsumerGroup(CONSUMER_GROUP);
+ RemotingCommand request = RemotingCommand.createRequestCommand(
+ RequestCode.GET_CONSUMER_LIST_BY_GROUP, header);
+ request.makeCustomHeaderToNet();
+ when(messagingProcessor.getConsumerGroupInfo(any(), eq(CONSUMER_GROUP))).thenReturn(null);
+
+ RemotingCommand response = consumerManagerActivity.getConsumerListByGroup(
+ null, request, ProxyContext.create());
+
+ assertThat(response.getCode()).isEqualTo(ResponseCode.CONSUMER_NOT_ONLINE);
+ assertThat(response.getRemark()).isEqualTo("the consumer group[offline-group] not online");
Review Comment:
The test asserts the full `remark` string exactly, which can make the test brittle if the message wording changes while behavior remains correct. Consider asserting key invariants instead (e.g., remark contains the consumer group and indicates not-online), or centralizing the remark message construction so production and test share the same source of truth.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE #10793] Handle offline consumer list queries [rocketmq]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #10794:
URL: https://github.com/apache/rocketmq/pull/10794#issuecomment-5168585135
## [Codecov](https://app.codecov.io/gh/apache/rocketmq/pull/10794?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `75.00000%` with `1 line` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 48.23%. Comparing base ([`eddb235`](https://app.codecov.io/gh/apache/rocketmq/commit/eddb235c1bd8adc5c3a1125a294405526e7bb0e3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`5ed5374`](https://app.codecov.io/gh/apache/rocketmq/commit/5ed5374bb992d9179ce2466c9bd6ea46a6301685?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/rocketmq/pull/10794?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...oxy/remoting/activity/ConsumerManagerActivity.java](https://app.codecov.io/gh/apache/rocketmq/pull/10794?src=pr&el=tree&filepath=proxy%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fproxy%2Fremoting%2Factivity%2FConsumerManagerActivity.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L3JlbW90aW5nL2FjdGl2aXR5L0NvbnN1bWVyTWFuYWdlckFjdGl2aXR5LmphdmE=) | 75.00% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/10794?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## develop #10794 +/- ##
=============================================
- Coverage 48.30% 48.23% -0.07%
+ Complexity 13514 13492 -22
=============================================
Files 1380 1380
Lines 101104 101108 +4
Branches 13107 13108 +1
=============================================
- Hits 48834 48769 -65
- Misses 46300 46352 +52
- Partials 5970 5987 +17
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/rocketmq/pull/10794?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org