This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new a4dee573c fix(audit): record a cloud-accepted direct consume as a 
success (#5119)
a4dee573c is described below

commit a4dee573c2fef38ecd719b38dcfc532ebd32553d
Author: 烤化の初雪 <[email protected]>
AuthorDate: Mon Oct 19 20:52:30 2026 +0800

    fix(audit): record a cloud-accepted direct consume as a success (#5119)
    
    Verified against `rocketmq-studio` at 62d0ad92e before merging: the defect 
is still present on the
    current trunk and the change merges cleanly.
    
    Maintainer follow-ups on top of the contributor commit:
    - fix(audit): grade a cloud-accepted direct consume as PARTIAL
    
    Each follow-up commit message records the review finding it addresses.
    
    Locally verified: targeted suites green on the integration branch; a full 
backend and frontend
    build plus test pass runs on the trunk once this batch lands.
---
 .../studio/instance/message/MessageService.java    | 14 ++++++++--
 .../instance/message/MessageServiceTest.java       | 30 ++++++++++++++++++++++
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/instance/message/MessageService.java
 
b/server/src/main/java/org/apache/rocketmq/studio/instance/message/MessageService.java
index 557363601..d5f8b7267 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/instance/message/MessageService.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/instance/message/MessageService.java
@@ -213,9 +213,19 @@ public class MessageService {
         return provider.consumeMessageDirectly(request);
     }
 
-    /** consumeResult mirrors the broker-side CMResult enum, where only 
CR_SUCCESS means consumed. */
+    /**
+     * Grade a direct consume with the shared audit vocabulary (SUCCESS / 
FAILED / PARTIAL, see
+     * docs/api-spec.md). consumeResult mirrors the broker-side CMResult enum, 
where only
+     * CR_SUCCESS means consumed. The cloud providers answer in their own 
vocabulary: Tencent
+     * returns REQUEST_ACCEPTED for a request the cloud accepted but whose 
consumption outcome it
+     * never reports, which is neither a confirmed success nor a failure — 
PARTIAL, matching the
+     * DLQ resend and cloud import classification. Every other answer failed.
+     */
     private static String auditResult(String consumeResult) {
-        return "CR_SUCCESS".equals(consumeResult) ? "SUCCESS" : "FAILED";
+        if ("CR_SUCCESS".equals(consumeResult)) {
+            return "SUCCESS";
+        }
+        return "REQUEST_ACCEPTED".equals(consumeResult) ? "PARTIAL" : "FAILED";
     }
 
     private void recordDirectConsumeAudit(DirectConsumeMessageDTO request, 
String detail,
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/instance/message/MessageServiceTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/instance/message/MessageServiceTest.java
index 04c961dee..6e8af546f 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/instance/message/MessageServiceTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/instance/message/MessageServiceTest.java
@@ -218,6 +218,36 @@ class MessageServiceTest {
                 org.mockito.ArgumentMatchers.eq("FAILED"), 
org.mockito.ArgumentMatchers.isNull());
     }
 
+    @Test
+    void auditsACloudAcceptedDirectConsumeAsPartialTest() {
+        MessageProvider fallback = mock(MessageProvider.class);
+        InstanceProvider provider = mock(InstanceProvider.class);
+        InstanceProviderRegistry registry = 
mock(InstanceProviderRegistry.class);
+        OperationAuditService audit = mock(OperationAuditService.class);
+        DirectConsumeMessageDTO request = new DirectConsumeMessageDTO();
+        request.setInstanceId("tencent-instance");
+        request.setTopic("orders");
+        request.setMsgId("msg-1");
+        request.setConsumerGroup("billing");
+        request.setClientId("client-a");
+        
when(registry.byInstanceId("tencent-instance")).thenReturn(Optional.of(provider));
+        
when(provider.capabilities()).thenReturn(Set.of(InstanceCapability.DIRECT_MESSAGE_CONSUME));
+        // The Tencent OpenAPI answers REQUEST_ACCEPTED: the cloud accepted 
the verification
+        // request and never reports the consumption outcome, so the audit 
grades it PARTIAL
+        // rather than claiming a SUCCESS it cannot observe.
+        
when(provider.consumeMessageDirectly(request)).thenReturn(DirectConsumeMessageResultVO.builder()
+                .consumeResult("REQUEST_ACCEPTED").build());
+        MessageService service = new MessageService(fallback, registry, 
mock(QueryHistoryService.class), audit, ownershipGuard());
+
+        service.consumeMessageDirectly(request);
+
+        
verify(audit).record(org.mockito.ArgumentMatchers.eq("DIRECT_CONSUME_MESSAGE"),
+                org.mockito.ArgumentMatchers.eq("MESSAGE"), 
org.mockito.ArgumentMatchers.eq("msg-1"),
+                org.mockito.ArgumentMatchers.eq("tencent-instance"),
+                org.mockito.ArgumentMatchers.contains("REQUEST_ACCEPTED"),
+                org.mockito.ArgumentMatchers.eq("PARTIAL"), 
org.mockito.ArgumentMatchers.isNull());
+    }
+
     @Test
     void auditsDirectConsumeFailureWhenProviderThrowsTest() {
         MessageProvider fallback = mock(MessageProvider.class);

Reply via email to