You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "unbridled-41 (via GitHub)" <gi...@apache.org> on 2026/09/20 11:15:23 UTC

[PR] fix(message): grade an offline direct-consume client as not found [rocketmq-dashboard]

unbridled-41 opened a new pull request, #4605:
URL: https://github.com/apache/rocketmq-dashboard/pull/4605

   Fixes #4601.
   
   ## Problem
   
   `POST /api/messages/direct-consume` answered HTTP 502 with the raw broker text when the typed consumer client is not connected, although "this client is not online" is a normal business state for a dialog whose group and client id are typed by hand.
   
   ## Evidence
   
   Regression test added with this PR (`RocketMQMessageProviderTest` → `directlyConsumesMessageReportsAnOfflineClientAsNotFound`), run against the pre-fix code (baseline `origin/master` = d50ffecc, provider restored while keeping the new test):
   
   ```
   Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
   java.lang.AssertionError:
   Expecting actual throwable to be an instance of:
     org.apache.rocketmq.studio.common.exception.BusinessException
   but was:
     org.apache.rocketmq.client.exception.MQClientException: CODE: 1  DESC: The Consumer billing client-offline not online
   For more information, please visit the url, https://rocketmq.apache.org/docs/bestPractice/06FAQ
   	at org.apache.rocketmq.tools.admin.DefaultMQAdminExt.consumeMessageDirectly(DefaultMQAdminExt.java:605)
   	at org.apache.rocketmq.studio.provider.apache.RocketMQMessageProvider.lambda$consumeMessageDirectly$5(RocketMQMessageProvider.java:500)
   ```
   
   `MqAdminExtFactory` wraps every non-`BusinessException` into `502 "RocketMQ admin call failed: " + rootMessage`, which is what the operator saw in the 直接消费 dialog.
   
   ## Root cause and fix
   
   `consumeMessageDirectly` delegated to the admin client without grading exceptions, so the broker's `SYSTEM_ERROR` (code 1) answer for an offline client travelled to the generic 502 wrapper. The sibling endpoint that reports on the same consumer client already treats that answer as a business state — `RocketMQConsumerDiagnosticsProvider#diagnosticsFailure` maps a root message containing `not online` to `404 "Consumer client is not reachable from any proxy or broker"`. This PR gives the direct-consume path the same grading and keeps every other broker failure as a 502 with the original message shape.
   
   ## Priority and scoring
   
   PRIORITY 73 = impact 28 + scope 11 + reproducibility 18 + maintenance value 16.
   
   - Impact 28: an actionable condition is presented as a gateway failure with raw broker text; a client-side failure also counts as a 5xx in any monitoring.
   - Scope 11: the direct-consume path of every Apache instance.
   - Reproducibility 18: deterministic, covered by two added tests (offline client → 404, other failure → 502).
   - Maintenance value 16: the same condition is already graded as a not-found state on the consumer stack endpoint, so the codebase carries two answers for one broker reply.
   
   FIX_CONFIDENCE 92: local grading in one method, no interface or signature change; the sibling implementation is the template.
   
   ## Tests
   
   - Red (baseline source + new test): `Tests run: 1, Failures: 1` with the raw `MQClientException` shown above.
   - Green: `SPRING_PROFILES_ACTIVE=dev mvn -o -Dtest=RocketMQMessageProviderTest test` → **Tests run: 56, Failures: 0, Errors: 0** (54 pre-existing + 2 new).
   - Related suites: `MessageServiceTest` 19/19, `MessageControllerTest` 6/6.
   - `mvn -o checkstyle:check` → clean.
   
   ## Risk
   
   Low. Only the exception grading of this one call changed. The 502 path is preserved for every other failure (covered by `directlyConsumesMessageKeepsOtherBrokerFailuresAsBadGateway`). The 404 message names the client id and group instead of the raw broker remark, which is what the consumer-stack endpoint already does for the same condition.
   


-- 
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] fix(message): grade an offline direct-consume client as not found [rocketmq-dashboard]

Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins merged PR #4605:
URL: https://github.com/apache/rocketmq-dashboard/pull/4605


-- 
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] fix(message): grade an offline direct-consume client as not found [rocketmq-dashboard]

Posted by "unbridled-41 (via GitHub)" <gi...@apache.org>.
unbridled-41 commented on PR #4605:
URL: https://github.com/apache/rocketmq-dashboard/pull/4605#issuecomment-5749650931

   ## Verification evidence
   
   **CI (this head SHA)** — `bf7d80e7af75273b54778eeba842ca34140dc9d9`: exactly one `CI` (`pull_request`) run, id `35507319061`, `status=completed`, `conclusion=startup_failure`; `check-runs=0`; combined status `state=pending, count=0`. Repo-wide condition: every recent `pull_request` run is `startup_failure`, including other contributors' PRs.
   
   **Red before the fix** — provider restored from `origin/master` with the new tests kept:
   
   ```
   SPRING_PROFILES_ACTIVE=dev mvn -o -Dtest='RocketMQMessageProviderTest#directlyConsumesMessageReportsAnOfflineClientAsNotFound' test
   
   Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
   java.lang.AssertionError:
   Expecting actual throwable to be an instance of:
     org.apache.rocketmq.studio.common.exception.BusinessException
   but was:
     org.apache.rocketmq.client.exception.MQClientException: CODE: 1  DESC: The Consumer billing client-offline not online
   For more information, please visit the url, https://rocketmq.apache.org/docs/bestPractice/06FAQ
   	at org.apache.rocketmq.tools.admin.DefaultMQAdminExt.consumeMessageDirectly(DefaultMQAdminExt.java:605)
   	at org.apache.rocketmq.studio.provider.apache.RocketMQMessageProvider.lambda$consumeMessageDirectly$5(RocketMQMessageProvider.java:500)
   ```
   
   That raw client exception is what `MqAdminExtFactory` wrapped into `502 "RocketMQ admin call failed: " + rootMessage` before this change.
   
   **Module tests (green)**
   
   ```
   SPRING_PROFILES_ACTIVE=dev mvn -o -Dtest='RocketMQMessageProviderTest,MessageServiceTest,MessageControllerTest' test
   
   Tests run: 56, Failures: 0, Errors: 0, Skipped: 0 -- RocketMQMessageProviderTest   (54 pre-existing + 2 new)
   Tests run: 19, Failures: 0, Errors: 0, Skipped: 0 -- MessageServiceTest
   Tests run:  6, Failures: 0, Errors: 0, Skipped: 0 -- MessageControllerTest
   ```
   
   `mvn -o checkstyle:check`: clean.
   
   **Full backend suite** — `cd server && SPRING_PROFILES_ACTIVE=dev mvn -o test` on this branch:
   
   ```
   Tests run: 2416, Failures: 0, Errors: 0, Skipped: 0
   BUILD SUCCESS
   ```
   
   2416 = the pristine `origin/master` baseline recorded for this suite (2414) plus the two tests added here, with zero failures. A `BUILD SUCCESS` on the default `test` phase also covers the `backend-build` job's compile step.
   
   **Web suite** — not affected (this PR changes only `server/`), but recorded for completeness: `npx vitest run --maxWorkers=4` on this branch → `Tests 1033 passed | 1 failed (1034)`, the single failure being the load-sensitive `ConsumerPage > keeps the latest client stack when an older request resolves last`, which also fails with the file restored from `origin/master` under the same load.
   
   **Diff self-check** — `git diff --numstat origin/master` → `24/3 server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQMessageProvider.java`, `37/0 server/src/test/java/org/apache/rocketmq/studio/provider/apache/RocketMQMessageProviderTest.java` (2 files, net +61/−3). The `−3` are the three lines of the original unguarded call replaced by the graded `try/catch` plus the helper extracted at the bottom of the file.
   


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