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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]