This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 33bfb744a fix(tools): create a FIFO group with the console's default
order type (#6945)
33bfb744a is described below
commit 33bfb744a6551a3d428062634dbe619057360783
Author: bai mengxuan <[email protected]>
AuthorDate: Fri Nov 27 12:21:58 2026 +0800
fix(tools): create a FIFO group with the console's default order type
(#6945)
---
.../group/ConsumerGroupUpdateToolHandler.java | 20 ++++++++++++++++++--
.../tool/handler/group/GroupMutationPlanTest.java | 22 ++++++++++++++++++++++
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git
a/server/src/main/java/org/apache/rocketmq/studio/ops/ai/tool/handler/group/ConsumerGroupUpdateToolHandler.java
b/server/src/main/java/org/apache/rocketmq/studio/ops/ai/tool/handler/group/ConsumerGroupUpdateToolHandler.java
index ac0b762cd..96a172c12 100644
---
a/server/src/main/java/org/apache/rocketmq/studio/ops/ai/tool/handler/group/ConsumerGroupUpdateToolHandler.java
+++
b/server/src/main/java/org/apache/rocketmq/studio/ops/ai/tool/handler/group/ConsumerGroupUpdateToolHandler.java
@@ -25,6 +25,7 @@ import
org.apache.rocketmq.studio.ops.ai.tool.contract.group.GroupListItem;
import org.apache.rocketmq.studio.ops.ai.tool.contract.plan.PlanDescription;
import org.apache.rocketmq.studio.ops.ai.tool.contract.plan.ToolPlan;
import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
import java.util.List;
@@ -55,7 +56,7 @@ public class ConsumerGroupUpdateToolHandler extends
MutationToolHandler<GroupInp
context.instanceId(), input.groupName()).orElse(null);
GroupInput before = current == null ? null : GroupInput.from(current);
GroupInput after = current == null
- ? GroupInput.from(input.toConsumerGroupVO())
+ ? GroupInput.from(createWithConsoleDefaults(input))
: GroupInput.from(input.mergeWith(current));
return PLAN_DESCRIPTION.builder(input.groupName(),
context.instanceId())
.before(before)
@@ -65,13 +66,28 @@ public class ConsumerGroupUpdateToolHandler extends
MutationToolHandler<GroupInp
.build();
}
+ /**
+ * The console's create dialog derives the order type from the
subscription data type: selecting
+ * FIFO mounts the order-type field with {@code PARTITON_ORDER} and every
create request carries
+ * it. A tool call that only names {@code subscriptionDataType=FIFO} must
not create a group whose
+ * broker configuration consumes unordered.
+ */
+ private static ConsumerGroupVO createWithConsoleDefaults(GroupInput input)
{
+ ConsumerGroupVO group = input.toConsumerGroupVO();
+ if ("FIFO".equalsIgnoreCase(group.getSubscriptionDataType())
+ && !StringUtils.hasText(group.getDeliveryOrderType())) {
+ group.setDeliveryOrderType("PARTITON_ORDER");
+ }
+ return group;
+ }
+
@Override
public GroupListItem execute(GroupInput input, ToolExecutionContext
context) {
// Update when present, create when absent; both persist idempotently.
ConsumerGroupVO current = metadataService.findConsumerGroup(
context.instanceId(), input.groupName()).orElse(null);
ConsumerGroupVO group = current == null
- ? input.toConsumerGroupVO()
+ ? createWithConsoleDefaults(input)
: input.mergeWith(current);
group.setInstanceId(context.instanceId());
return GroupListItem.from(current == null
diff --git
a/server/src/test/java/org/apache/rocketmq/studio/ops/ai/tool/handler/group/GroupMutationPlanTest.java
b/server/src/test/java/org/apache/rocketmq/studio/ops/ai/tool/handler/group/GroupMutationPlanTest.java
index 2f66ed7af..2cdf2169b 100644
---
a/server/src/test/java/org/apache/rocketmq/studio/ops/ai/tool/handler/group/GroupMutationPlanTest.java
+++
b/server/src/test/java/org/apache/rocketmq/studio/ops/ai/tool/handler/group/GroupMutationPlanTest.java
@@ -36,6 +36,7 @@ import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -152,6 +153,27 @@ class GroupMutationPlanTest {
verify(metadataService, never()).updateConsumerGroup(any());
}
+ @Test
+ void updateCreatesAFifoGroupWithTheConsolesDefaultOrderTypeTest() {
+ MetadataService metadataService = mock(MetadataService.class);
+ when(metadataService.findConsumerGroup(any(),
eq("new-fifo"))).thenReturn(Optional.empty());
+ ConsumerGroupVO created = new ConsumerGroupVO();
+ created.setName("new-fifo");
+ when(metadataService.createConsumerGroup(any())).thenReturn(created);
+
+ // The console's FIFO selector mounts the order-type field with
PARTITON_ORDER and always
+ // sends it; a tool call that only names the subscription data type
must not create an
+ // unordered group.
+ var input = Map.<String, Object>of("instanceId", "cluster-a",
"groupName", "new-fifo",
+ "subscriptionDataType", "FIFO");
+ ToolExecutionContext ctx = context("rmq.group.update", input);
+ new ConsumerGroupUpdateToolHandler(metadataService).execute(
+
ctx.convertInput(org.apache.rocketmq.studio.ops.ai.tool.contract.group.GroupInput.class),
ctx);
+
+ verify(metadataService).createConsumerGroup(argThat(group ->
+ "PARTITON_ORDER".equals(group.getDeliveryOrderType())));
+ }
+
@Test
void resetOffsetWithoutTimestampIsRejectedTest() {
// Decision 13: timestamp is required; the current-time default lives
in the rmqctl client.