Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(rabbitmq): preserve queue metrics and features

jearhe68d93c94275e
diff --git a/agents/drivers/rabbitmq/helpers.go b/agents/drivers/rabbitmq/helpers.go
index c01784f61f..a9e5108b68 100644
--- a/agents/drivers/rabbitmq/helpers.go
+++ b/agents/drivers/rabbitmq/helpers.go
@@ -214,23 +214,31 @@ func floatOrNull(object jsonObject, key string) *float64 {
}
func boolOrDefault(object jsonObject, key string, fallback bool) bool {
- if object == nil {
+ value := boolOrNull(object, key)
+ if value == nil {
return fallback
}
+ return *value
+}
+
+func boolOrNull(object jsonObject, key string) *bool {
+ if object == nil {
+ return nil
+ }
value, exists := object[key]
if !exists || value == nil {
- return fallback
+ return nil
}
switch typed := value.(type) {
case bool:
- return typed
+ return &typed
case string:
parsed, err := strconv.ParseBool(typed)
if err == nil {
- return parsed
+ return &parsed
}
}
- return fallback
+ return nil
}
func integerProperty(properties jsonObject, key string) (int, bool) {
diff --git a/agents/drivers/rabbitmq/mapping_test.go b/agents/drivers/rabbitmq/mapping_test.go
index 6f31ac15c8..91e0045d3c 100644
--- a/agents/drivers/rabbitmq/mapping_test.go
+++ b/agents/drivers/rabbitmq/mapping_test.go
@@ -1,6 +1,9 @@
package main
-import "testing"
+import (
+ "encoding/json"
+ "testing"
+)
func TestConsumersFromQueueInfo(t *testing.T) {
info := mustObject(t, `{
@@ -126,6 +129,9 @@ func TestTopicInfoMappingIncludesQueueMessageCounts(t *testing.T) {
if topic["messages"] != int64(12) || topic["messagesReady"] != int64(10) || topic["messagesUnacked"] != int64(2) {
t.Fatalf("unexpected topic counts %#v", topic)
}
+ if topic["consumers"] != int64(3) {
+ t.Fatalf("expected consumers wire field, got %#v", topic)
+ }
minimal := topicInfoFromJSON(mustObject(t, `{"name":"empty"}`))
if _, ok := minimal["messagesReady"]; ok {
@@ -143,3 +149,196 @@ func TestAttachVhost(t *testing.T) {
t.Fatalf("unexpected info %#v", info)
}
}
+
+func TestTopicInfoMappingIncludesQueueFeaturesAndArguments(t *testing.T) {
+ topic := topicInfoFromJSON(mustObject(t, `{
+ "name": "orders",
+ "durable": true,
+ "auto_delete": false,
+ "exclusive": true,
+ "state": "running",
+ "type": "quorum",
+ "messages": 123,
+ "messages_ready": 100,
+ "messages_unacknowledged": 23,
+ "consumers": 4,
+ "arguments": {
+ "x-queue-type": "quorum",
+ "x-message-ttl": 60000,
+ "x-max-length": 1000,
+ "x-queue-master-locator": "random"
+ }
+ }`))
+
+ if topic["durable"] != true || topic["autoDelete"] != false || topic["exclusive"] != true {
+ t.Fatalf("unexpected features %#v", topic)
+ }
+ if topic["state"] != "running" || topic["queueType"] != "quorum" {
+ t.Fatalf("unexpected state/type %#v", topic)
+ }
+ if topic["messages"] != int64(123) || topic["messagesReady"] != int64(100) ||
+ topic["messagesUnacked"] != int64(23) || topic["consumers"] != int64(4) {
+ t.Fatalf("unexpected counts %#v", topic)
+ }
+ arguments := topic["arguments"].(jsonObject)
+ // Argument values must keep their real JSON types, not be stringified:
+ // numbers survive as json.Number and booleans/strings pass through.
+ if ttl, ok := arguments["x-message-ttl"].(json.Number); !ok || ttl.String() != "60000" {
+ t.Fatalf("unexpected x-message-ttl %#v", arguments["x-message-ttl"])
+ }
+ if arguments["x-queue-type"] != "quorum" || arguments["x-queue-master-locator"] != "random" {
+ t.Fatalf("unexpected arguments %#v", arguments)
+ }
+}
+
+func TestTopicInfoMappingFallsBackToXQueueTypeArgument(t *testing.T) {
+ // Older RabbitMQ versions do not report the explicit `type` field; the
+ // queue type then lives only in the x-queue-type argument.
+ topic := topicInfoFromJSON(mustObject(t, `{
+ "name": "stream-q",
+ "arguments": {"x-queue-type": "stream"}
+ }`))
+ if topic["queueType"] != "stream" {
+ t.Fatalf("expected x-queue-type fallback, got %#v", topic["queueType"])
+ }
+
+ minimal := topicInfoFromJSON(mustObject(t, `{"name": "plain"}`))
+ if _, exists := minimal["queueType"]; exists {
+ t.Fatalf("unexpected queueType %#v", minimal)
+ }
+ if _, exists := minimal["arguments"]; exists {
+ t.Fatalf("unexpected arguments %#v", minimal)
+ }
+ if _, exists := minimal["exclusive"]; exists {
+ t.Fatalf("unexpected exclusive %#v", minimal)
+ }
+}
+
+func TestTopicInfoMappingIncludesMessageStatsRates(t *testing.T) {
+ topic := topicInfoFromJSON(mustObject(t, `{
+ "name": "orders",
+ "message_stats": {
+ "publish": 1000,
+ "publish_details": {"rate": 12.5},
+ "deliver_get": 900,
+ "deliver_get_details": {"rate": 11.8},
+ "ack": 880,
+ "ack_details": {"rate": 11.2}
+ }
+ }`))
+ if topic["publishRate"] != 12.5 || topic["deliverRate"] != 11.8 || topic["ackRate"] != 11.2 {
+ t.Fatalf("unexpected rates %#v", topic)
+ }
+
+ // No message_stats: rates must be absent, not fabricated as zero.
+ withoutStats := topicInfoFromJSON(mustObject(t, `{"name": "idle", "messages": 0}`))
+ for _, key := range []string{"publishRate", "deliverRate", "ackRate"} {
+ if _, exists := withoutStats[key]; exists {
+ t.Fatalf("unexpected %s in %#v", key, withoutStats)
+ }
+ }
+
+ // A real sampled rate of zero is preserved as zero (distinct from absent).
+ zeroRate := topicInfoFromJSON(mustObject(t, `{
+ "name": "quiet",
+ "message_stats": {"publish_details": {"rate": 0}, "deliver_get_details": {"rate": 0}, "ack_details": {"rate": 0}}
+ }`))
+ if zeroRate["publishRate"] != 0.0 || zeroRate["deliverRate"] != 0.0 || zeroRate["ackRate"] != 0.0 {
+ t.Fatalf("expected preserved zero rates, got %#v", zeroRate)
+ }
+}
+
+func TestGetTopicStatsPreservesMessageStatsFromManagementPayload(t *testing.T) {
+ queue := mustObject(t, `{
+ "name": "orders",
+ "messages": 123,
+ "messages_ready": 100,
+ "messages_unacknowledged": 23,
+ "consumers": 4,
+ "message_stats": {
+ "publish": 1000,
+ "publish_details": {"rate": 12.5},
+ "deliver_get": 900,
+ "deliver_get_details": {"rate": 11.8},
+ "ack": 880,
+ "ack_details": {"rate": 11.2}
+ }
+ }`)
+ // Mirror the Management API branch of getTopicStats: counts + rates all
+ // flow through, and a queue without message_stats omits every rate key.
+ messages := longOrDefault(queue, "messages", 0)
+ result := jsonObject{
+ "name": "orders",
+ "messageCount": messages,
+ "consumerCount": longOrDefault(queue, "consumers", 0),
+ "totalMessages": messages,
+ }
+ putIfPresent(result, "messagesReady", longOrNull(queue, "messages_ready"))
+ putIfPresent(result, "messagesUnacked", longOrNull(queue, "messages_unacknowledged"))
+ if stats := objectOrNil(queue, "message_stats"); stats != nil {
+ putIfPresent(result, "publishRate", rateFromDetails(stats, "publish_details"))
+ putIfPresent(result, "deliverRate", rateFromDetails(stats, "deliver_get_details"))
+ putIfPresent(result, "ackRate", rateFromDetails(stats, "ack_details"))
+ putIfPresent(result, "publishTotal", longOrNull(stats, "publish"))
+ putIfPresent(result, "deliverGetTotal", longOrNull(stats, "deliver_get"))
+ putIfPresent(result, "ackTotal", longOrNull(stats, "ack"))
+ }
+
+ if result["messageCount"] != int64(123) || result["messagesReady"] != int64(100) ||
+ result["messagesUnacked"] != int64(23) || result["consumerCount"] != int64(4) {
+ t.Fatalf("unexpected counts %#v", result)
+ }
+ if result["publishRate"] != 12.5 || result["deliverRate"] != 11.8 || result["ackRate"] != 11.2 {
+ t.Fatalf("unexpected rates %#v", result)
+ }
+ if result["publishTotal"] != int64(1000) || result["deliverGetTotal"] != int64(900) || result["ackTotal"] != int64(880) {
+ t.Fatalf("unexpected totals %#v", result)
+ }
+
+ withoutStats := jsonObject{"name": "idle", "messageCount": 0, "consumerCount": 0, "totalMessages": 0}
+ for _, key := range []string{"publishRate", "deliverRate", "ackRate", "publishTotal", "deliverGetTotal", "ackTotal"} {
+ if _, exists := withoutStats[key]; exists {
+ t.Fatalf("unexpected %s in %#v", key, withoutStats)
+ }
+ }
+}
+
+func TestGetTopicConfigPreservesArgumentTypes(t *testing.T) {
+ configs := jsonObject{}
+ object := mustObject(t, `{
+ "durable": true,
+ "auto_delete": false,
+ "exclusive": false,
+ "type": "quorum",
+ "arguments": {
+ "x-message-ttl": 60000,
+ "x-max-priority": 5,
+ "x-queue-type": "quorum",
+ "x-dead-letter-exchange": "dlx",
+ "x-single-active-consumer": true
+ }
+ }`)
+ configs["durable"] = boolOrDefault(object, "durable", false)
+ configs["auto_delete"] = boolOrDefault(object, "auto_delete", false)
+ configs["exclusive"] = boolOrDefault(object, "exclusive", false)
+ if queueType := queueTypeFromQueue(object); queueType != "" {
+ configs["queue_type"] = queueType
+ }
+ if arguments := objectOrNil(object, "arguments"); arguments != nil {
+ for key, value := range arguments {
+ configs[key] = value
+ }
+ }
+
+ if configs["queue_type"] != "quorum" || configs["durable"] != true {
+ t.Fatalf("unexpected config %#v", configs)
+ }
+ // Numbers and booleans keep their types instead of fmt.Sprint strings:
+ // the decoder produced json.Number, and pass-through preserves it verbatim.
+ if ttl, ok := configs["x-message-ttl"].(json.Number); !ok || ttl.String() != "60000" {
+ t.Fatalf("unexpected x-message-ttl type %#v", configs["x-message-ttl"])
+ }
+ if configs["x-single-active-consumer"] != true || configs["x-dead-letter-exchange"] != "dlx" {
+ t.Fatalf("unexpected argument values %#v", configs)
+ }
+}
diff --git a/agents/drivers/rabbitmq/operations.go b/agents/drivers/rabbitmq/operations.go
index df60510f24..fdcdf75482 100644
--- a/agents/drivers/rabbitmq/operations.go
+++ b/agents/drivers/rabbitmq/operations.go
@@ -63,9 +63,36 @@ func topicInfoFromJSON(queue jsonObject) jsonObject {
}
putIfPresent(info, "messagesReady", longOrNull(queue, "messages_ready"))
putIfPresent(info, "messagesUnacked", longOrNull(queue, "messages_unacknowledged"))
+ putIfPresent(info, "exclusive", boolOrNull(queue, "exclusive"))
+ if queueType := queueTypeFromQueue(queue); queueType != "" {
+ info["queueType"] = queueType
+ }
+ if arguments := objectOrNil(queue, "arguments"); arguments != nil && len(arguments) > 0 {
+ // Preserve original JSON types (numbers, booleans, nested values); the
+ // management API already decoded them, so pass them through verbatim.
+ info["arguments"] = arguments
+ }
+ if stats := objectOrNil(queue, "message_stats"); stats != nil {
+ putIfPresent(info, "publishRate", rateFromDetails(stats, "publish_details"))
+ putIfPresent(info, "deliverRate", rateFromDetails(stats, "deliver_get_details"))
+ putIfPresent(info, "ackRate", rateFromDetails(stats, "ack_details"))
+ }
return info
}
+// queueTypeFromQueue prefers the management API's explicit `type` field
+// (classic/quorum/stream, present on newer RabbitMQ versions) and falls back
+// to the x-queue-type argument for older versions that only report it there.
+func queueTypeFromQueue(queue jsonObject) string {
+ if explicit := stringOrEmpty(queue, "type"); explicit != "" {
+ return explicit
+ }
+ if arguments := objectOrNil(queue, "arguments"); arguments != nil {
+ return stringOrEmpty(arguments, "x-queue-type")
+ }
+ return ""
+}
+
func (s *server) createTopic(params jsonObject) (any, error) {
channel, err := s.channelFor(params)
if err != nil {
@@ -116,13 +143,29 @@ func (s *server) getTopicStats(params jsonObject) (any, error) {
"/api/queues/"+urlEncodeVhost(vhost)+"/"+urlEncodePathSegment(name))
if managementError == nil {
if info, ok := queue.(map[string]any); ok {
- messages := longOrDefault(jsonObject(info), "messages", 0)
- return jsonObject{
+ object := jsonObject(info)
+ messages := longOrDefault(object, "messages", 0)
+ result := jsonObject{
"name": name,
"messageCount": messages,
- "consumerCount": longOrDefault(jsonObject(info), "consumers", 0),
+ "consumerCount": longOrDefault(object, "consumers", 0),
"totalMessages": messages,
- }, nil
+ }
+ putIfPresent(result, "messagesReady", longOrNull(object, "messages_ready"))
+ putIfPresent(result, "messagesUnacked", longOrNull(object, "messages_unacknowledged"))
+ if stats := objectOrNil(object, "message_stats"); stats != nil {
+ // Rates are only emitted when the management API actually
+ // sampled them; a missing entry stays absent so callers can
+ // distinguish "no data" from a real rate of zero.
+ putIfPresent(result, "publishRate", rateFromDetails(stats, "publish_details"))
+ putIfPresent(result, "deliverRate", rateFromDetails(stats, "deliver_get_details"))
+ putIfPresent(result, "ackRate", rateFromDetails(stats, "ack_details"))
+ // Cumulative counters, matching the management UI's totals.
+ putIfPresent(result, "publishTotal", longOrNull(stats, "publish"))
+ putIfPresent(result, "deliverGetTotal", longOrNull(stats, "deliver_get"))
+ putIfPresent(result, "ackTotal", longOrNull(stats, "ack"))
+ }
+ return result, nil
}
} else {
fmt.Fprintln(os.Stderr, "Management API unavailable for queue stats, falling back to passive declare: "+managementError.Error())
@@ -164,13 +207,15 @@ func (s *server) getTopicConfig(params jsonObject) (any, error) {
configs["durable"] = boolOrDefault(object, "durable", false)
configs["auto_delete"] = boolOrDefault(object, "auto_delete", false)
configs["exclusive"] = boolOrDefault(object, "exclusive", false)
+ if queueType := queueTypeFromQueue(object); queueType != "" {
+ configs["queue_type"] = queueType
+ }
if arguments := objectOrNil(object, "arguments"); arguments != nil {
+ // Preserve the real JSON types the management API returned
+ // (numbers, booleans, nested values) instead of stringifying
+ // every argument, so config round-trips and display stay true.
for key, value := range arguments {
- if value == nil {
- configs[key] = nil
- } else {
- configs[key] = fmt.Sprint(value)
- }
+ configs[key] = value
}
}
}
@@ -1345,6 +1390,10 @@ func putIfPresent(info jsonObject, key string, value any) {
if typed != nil {
info[key] = *typed
}
+ case *bool:
+ if typed != nil {
+ info[key] = *typed
+ }
case nil:
default:
info[key] = typed
diff --git a/apps/desktop/src/components/mq/MonitoringPanel.vue b/apps/desktop/src/components/mq/MonitoringPanel.vue
index 4a89c8b2a5..5e6b185cbe 100644
--- a/apps/desktop/src/components/mq/MonitoringPanel.vue
+++ b/apps/desktop/src/components/mq/MonitoringPanel.vue
@@ -25,8 +25,8 @@ interface Props {
interface MetricPoint {
time: string;
- msgRateIn: number;
- msgRateOut: number;
+ msgRateIn: number | null;
+ msgRateOut: number | null;
backlogSize: number;
msgBacklog: number;
consumerLagMs: number;
@@ -72,6 +72,16 @@ const selectedPartitionName = ref<string>();
let refreshTimer: number | undefined;
const history = ref<MetricPoint[]>([]);
const MAX_HISTORY_POINTS = 60;
+const messageFlowStatus = computed(() => {
+ if (!stats.value || stats.value.ratesUnavailable) {
+ return { kind: "unavailable", label: "-" };
+ }
+ const active = stats.value.msgRateIn > 0 || stats.value.msgRateOut > 0;
+ return {
+ kind: active ? "healthy" : "idle",
+ label: active ? t("mqMonitoring.flowActive") : t("mqMonitoring.flowIdle"),
+ };
+});
const partitionRows = computed(() => extractPartitionRows(stats.value?.raw));
const kafkaPartitionRows = computed(() => extractKafkaPartitionRows(stats.value?.raw));
@@ -213,10 +223,11 @@ function refreshNow() {
}
function appendHistoryPoint(statsData: TopicStats, backlogData?: BacklogStats) {
+ const ratesUnavailable = statsData.ratesUnavailable === true;
const point: MetricPoint = {
time: new Date().toLocaleTimeString(),
- msgRateIn: statsData.msgRateIn,
- msgRateOut: statsData.msgRateOut,
+ msgRateIn: ratesUnavailable ? null : statsData.msgRateIn,
+ msgRateOut: ratesUnavailable ? null : statsData.msgRateOut,
backlogSize: statsData.backlogSize,
msgBacklog: backlogData?.msgBacklog ?? 0,
consumerLagMs: extractConsumerLagMs(statsData.raw),
@@ -351,6 +362,10 @@ function formatNumber(num: number): string {
return num.toLocaleString();
}
+function formatMessageRate(rate: number, unavailable?: boolean): string {
+ return unavailable ? "-" : `${rate.toFixed(2)} msg/s`;
+}
+
watch(
() => props.topic,
() => {
@@ -615,14 +630,14 @@ onUnmounted(() => {
<div class="stat-icon"><Download :size="21" /></div>
<div class="stat-content">
<div class="stat-label">{{ t("mqMonitoring.inboundRate") }}</div>
- <div class="stat-value">{{ stats.msgRateIn.toFixed(2) }} msg/s</div>
+ <div class="stat-value" data-testid="monitoring-rate-in">{{ formatMessageRate(stats.msgRateIn, stats.ratesUnavailable) }}</div>
</div>
</div>
<div class="stat-card">
<div class="stat-icon"><Upload :size="21" /></div>
<div class="stat-content">
<div class="stat-label">{{ t("mqMonitoring.outboundRate") }}</div>
- <div class="stat-value">{{ stats.msgRateOut.toFixed(2) }} msg/s</div>
+ <div class="stat-value" data-testid="monitoring-rate-out">{{ formatMessageRate(stats.msgRateOut, stats.ratesUnavailable) }}</div>
</div>
</div>
<div class="stat-card">
@@ -645,7 +660,7 @@ onUnmounted(() => {
<div class="charts-grid">
<div class="chart-panel">
<h4>{{ t("mqMonitoring.rateTrend") }}</h4>
- <VChart :option="rateChartOption" autoresize class="trend-chart" />
+ <VChart :option="rateChartOption" autoresize class="trend-chart" data-testid="monitoring-rate-chart" />
</div>
<div class="chart-panel">
<h4>{{ t("mqMonitoring.backlogTrend") }}</h4>
@@ -820,8 +835,8 @@ onUnmounted(() => {
<div class="health-indicators">
<div class="health-item">
<span class="health-label">{{ t("mqMonitoring.messageFlow") }}:</span>
- <span :class="['health-badge', stats.msgRateIn > 0 || stats.msgRateOut > 0 ? 'healthy' : 'idle']">
- {{ stats.msgRateIn > 0 || stats.msgRateOut > 0 ? t("mqMonitoring.flowActive") : t("mqMonitoring.flowIdle") }}
+ <span :class="['health-badge', messageFlowStatus.kind]" data-testid="monitoring-flow-status">
+ {{ messageFlowStatus.label }}
</span>
</div>
<div class="health-item">
@@ -1467,6 +1482,11 @@ onUnmounted(() => {
color: var(--monitor-muted);
}
+.health-badge.unavailable {
+ background: color-mix(in srgb, var(--monitor-muted) 8%, transparent);
+ color: var(--monitor-muted);
+}
+
.monitoring-message-heading {
display: flex;
align-items: center;
diff --git a/apps/desktop/src/components/mq/TopicsPanel.vue b/apps/desktop/src/components/mq/TopicsPanel.vue
index c8bba83cca..6609388d3c 100644
--- a/apps/desktop/src/components/mq/TopicsPanel.vue
+++ b/apps/desktop/src/components/mq/TopicsPanel.vue
@@ -12,6 +12,7 @@ import ExchangesPanel from "./ExchangesPanel.vue";
import MqTypeFilterBar from "./shared/MqTypeFilterBar.vue";
import type { MqTab } from "@/lib/mq/mqConsoleDefaults";
import { isAllVhostsNamespace, resolveMqRowNamespace } from "@/lib/mq/mqConsoleDefaults";
+import { formatMqRateCompact, rabbitMqArgumentsSummary, rabbitMqFeatureBadges, rabbitMqQueueType, type RabbitMqFeatureBadge } from "@/lib/mq/rabbitmqQueueFeatures";
import { formatError } from "@/lib/backend/errorUtils";
import { DEFAULT_ROCKETMQ_TOPIC_TYPE_FILTERS, isProtectedRocketMqTopic, isRocketMqBusinessMessageType, matchesRocketMqTypeFilters, resolveRocketMqMessageType, ROCKETMQ_CREATABLE_TOPIC_MESSAGE_TYPES, ROCKETMQ_TOPIC_MESSAGE_TYPES } from "@/lib/mq/rocketmqTopicTypes";
import { useMqMutationGuard } from "@/composables/useMqMutationGuard";
@@ -141,22 +142,35 @@ const virtualTopicRows = computed<VirtualTopicRow[]>(() =>
const topicsGridTemplate = computed(() => {
const cols: string[] = ["minmax(180px, 1.6fr)"];
if (showNamespaceColumn.value) cols.push("minmax(100px, 0.8fr)");
- cols.push("120px");
- if (!isRocketMqCluster.value) cols.push("140px");
+ if (isRabbitMqCluster.value) {
+ // RabbitMQ queues: type(+state) | features | messages | consumers | rates | actions
+ cols.push("110px", "170px", "90px", "70px", "190px");
+ } else {
+ cols.push("120px");
+ }
+ if (!isRocketMqCluster.value && !isRabbitMqCluster.value) cols.push("140px");
// RocketMQ keeps tiled row actions (status/route/consumers/…) — reserve a wider actions column.
- cols.push(isRocketMqCluster.value ? "minmax(560px, 2.2fr)" : "minmax(200px, 1fr)");
+ cols.push(isRocketMqCluster.value ? "minmax(560px, 2.2fr)" : "minmax(150px, 1fr)");
return cols.join(" ");
});
/** Min content width from grid track mins + gaps + padding; enables shared horizontal scroll. */
const topicsTableMinWidthPx = computed(() => {
- let min = 180 + 120; // name + type
+ let min = 180; // name
if (showNamespaceColumn.value) min += 100;
- if (!isRocketMqCluster.value) min += 140;
- min += isRocketMqCluster.value ? 560 : 200;
- let colCount = 3;
+ let colCount = 0;
+ if (isRabbitMqCluster.value) {
+ // type + features + messages + consumers + rates + actions
+ min += 110 + 170 + 90 + 70 + 190 + 150;
+ colCount = 7; // name, type, features, messages, consumers, rates, actions
+ } else {
+ min += 120; // type
+ if (!isRocketMqCluster.value) min += 140; // partitions
+ min += isRocketMqCluster.value ? 560 : 200; // actions
+ // RocketMQ: name + type + actions. Others: + partitions.
+ colCount = isRocketMqCluster.value ? 3 : 4;
+ }
if (showNamespaceColumn.value) colCount += 1;
- if (!isRocketMqCluster.value) colCount += 1;
min += (colCount - 1) * 8; // column-gap
min += 24; // horizontal padding
return min;
@@ -177,6 +191,37 @@ function rabbitMqReadyMessageCount(topic: TopicInfo): number {
return topic.messagesReady ?? topic.messageCount ?? 0;
}
+/** Queue type label for the type column; unknown types are never guessed. */
+function rabbitMqQueueTypeLabel(topic: TopicInfo): string {
+ return rabbitMqQueueType(topic) ?? t("mqTopics.rabbitmqQueueTypeUnknown");
+}
+
+function rabbitMqQueueTypeBadgeClass(topic: TopicInfo): string {
+ const type = rabbitMqQueueType(topic);
+ if (type === "quorum") return "badge-info";
+ if (type === "stream") return "badge-warning";
+ return "badge-default";
+}
+
+function rabbitMqFeatureBadgesFor(topic: TopicInfo): RabbitMqFeatureBadge[] {
+ return rabbitMqFeatureBadges(topic);
+}
+
+/** Tooltip for the message-count column: Ready / Unacked / Total / Consumers. */
+function rabbitMqMessageCountTitle(topic: TopicInfo): string {
+ const parts = [`${t("mqRabbitMqMonitoring.messagesReady")}: ${topic.messagesReady ?? "-"}`, `${t("mqRabbitMqMonitoring.messagesUnacked")}: ${topic.messagesUnacked ?? "-"}`, `${t("mqTopics.messageCount")}: ${topic.messageCount ?? "-"}`];
+ if (topic.consumerCount !== undefined) parts.push(`${t("mqTopics.consumers")}: ${topic.consumerCount}`);
+ if (topic.state) parts.push(`${t("mqTopics.rabbitmqState")}: ${topic.state}`);
+ const summary = rabbitMqArgumentsSummary(topic);
+ if (summary) parts.push(`${t("mqTopics.rabbitmqArguments")}: ${summary}`);
+ return parts.join(" · ");
+}
+
+/** Tooltip for the rates column; rates are msg/s sampled by the management API. */
+function rabbitMqRatesTitle(): string {
+ return `${t("mqTopics.rabbitmqPublishRate")} / ${t("mqTopics.rabbitmqDeliverRate")} / ${t("mqTopics.rabbitmqAckRate")} (msg/s)`;
+}
+
function toggleRabbitMqMessageSort() {
rabbitMqMessageSort.value = rabbitMqMessageSort.value === "desc" ? "asc" : "desc";
}
@@ -551,7 +596,9 @@ watch(newPartitions, () => {
<div class="topics-table-header" :style="{ gridTemplateColumns: topicsGridTemplate }">
<div class="topics-col">{{ t("mqTopics.name") }}</div>
<div v-if="showNamespaceColumn" class="topics-col">{{ t("mqAdmin.namespace") }}</div>
- <div class="topics-col">{{ t("mqTopics.type") }}</div>
+ <div v-if="isRabbitMqCluster" class="topics-col">{{ t("mqTopics.rabbitmqQueueType") }}</div>
+ <div v-else class="topics-col">{{ t("mqTopics.type") }}</div>
+ <div v-if="isRabbitMqCluster" class="topics-col">{{ t("mqTopics.rabbitmqFeatures") }}</div>
<div v-if="isRabbitMqCluster" class="topics-col">
<button type="button" class="topics-sort-button" data-testid="rabbitmq-message-sort" @click="toggleRabbitMqMessageSort">
{{ t("mqTopics.messageCount") }}
@@ -559,6 +606,8 @@ watch(newPartitions, () => {
</button>
</div>
<div v-else-if="!isRocketMqCluster" class="topics-col">{{ t("mqTopics.partitions") }}</div>
+ <div v-if="isRabbitMqCluster" class="topics-col">{{ t("mqTopics.consumers") }}</div>
+ <div v-if="isRabbitMqCluster" class="topics-col" :title="rabbitMqRatesTitle()">{{ t("mqTopics.rabbitmqRates") }}</div>
<div class="topics-col">{{ t("mqTopics.actions") }}</div>
</div>
<RecycleScroller class="topics-scroller" :items="virtualTopicRows" :item-size="TOPIC_ROW_HEIGHT" :buffer="200" key-field="id">
@@ -571,18 +620,40 @@ watch(newPartitions, () => {
</div>
</div>
<div v-if="showNamespaceColumn" class="topics-col">{{ row.topic.namespace || "-" }}</div>
- <div class="topics-col">
+ <div v-if="isRabbitMqCluster" class="topics-col">
+ <span class="badge" :class="rabbitMqQueueTypeBadgeClass(row.topic)" :title="t('mqTopics.rabbitmqQueueTypeHint')">
+ {{ rabbitMqQueueTypeLabel(row.topic) }}
+ </span>
+ <span v-if="row.topic.state" class="queue-state" :title="t('mqTopics.rabbitmqState')">{{ row.topic.state }}</span>
+ </div>
+ <div v-else class="topics-col">
<span class="badge" :class="topicTypeBadgeClass(row.topic)">
{{ topicTypeLabel(row.topic) }}
</span>
</div>
- <div v-if="isRabbitMqCluster" class="topics-col" data-testid="rabbitmq-message-count" :title="`${t('mqRabbitMqMonitoring.messagesReady')}: ${rabbitMqReadyMessageCount(row.topic)} · ${t('mqRabbitMqMonitoring.messagesUnacked')}: ${row.topic.messagesUnacked ?? 0}`">
+ <div v-if="isRabbitMqCluster" class="topics-col" data-testid="rabbitmq-features">
+ <span v-if="rabbitMqFeatureBadgesFor(row.topic).length" class="feature-badges">
+ <span v-for="badge in rabbitMqFeatureBadgesFor(row.topic)" :key="badge.key" class="feature-badge" :class="badge.kind === 'feature' ? 'feature-flag' : ''" :title="badge.title">
+ {{ badge.label }}
+ </span>
+ </span>
+ <span v-else class="text-muted">-</span>
+ </div>
+ <div v-if="isRabbitMqCluster" class="topics-col" data-testid="rabbitmq-message-count" :title="rabbitMqMessageCountTitle(row.topic)">
{{ rabbitMqReadyMessageCount(row.topic) }}
</div>
<div v-else-if="!isRocketMqCluster" class="topics-col">
<span v-if="row.topic.partitioned">{{ row.topic.partitions ? t("mqTopics.partitionCount", { count: row.topic.partitions }) : t("mqTopics.partitionsUnknown") }}</span>
<span v-else class="text-muted">-</span>
</div>
+ <div v-if="isRabbitMqCluster" class="topics-col" data-testid="rabbitmq-consumers">{{ row.topic.consumerCount ?? "-" }}</div>
+ <div v-if="isRabbitMqCluster" class="topics-col topics-rates" data-testid="rabbitmq-rates" :title="rabbitMqRatesTitle()">
+ <span>{{ formatMqRateCompact(row.topic.publishRate) }}</span>
+ <span class="rate-sep">/</span>
+ <span>{{ formatMqRateCompact(row.topic.deliverRate) }}</span>
+ <span class="rate-sep">/</span>
+ <span>{{ formatMqRateCompact(row.topic.ackRate) }}</span>
+ </div>
<div class="topics-col actions" @click.stop>
<template v-if="isRocketMqCluster">
<button type="button" class="btn-sm" @click="openRocketMqDialog('status', row.topic)">{{ t("mqTopics.actionStatus") }}</button>
@@ -1037,6 +1108,53 @@ watch(newPartitions, () => {
font-style: italic;
}
+/* RabbitMQ queue feature badges (compact, tooltip-bearing). */
+.queue-state {
+ margin-left: 4px;
+ font-size: 11px;
+ color: var(--color-text-tertiary);
+ white-space: nowrap;
+}
+
+.feature-badges {
+ display: inline-flex;
+ gap: 3px;
+ flex-wrap: nowrap;
+ overflow: hidden;
+}
+
+.feature-badge {
+ display: inline-block;
+ padding: 1px 5px;
+ border-radius: var(--dbx-radius-fixed-4);
+ font-size: 10px;
+ font-weight: 600;
+ line-height: 1.5;
+ background: var(--color-background-secondary);
+ border: 1px solid var(--color-border);
+ color: var(--color-text-secondary);
+ white-space: nowrap;
+ cursor: help;
+}
+
+.feature-badge.feature-flag {
+ background: var(--color-warning-alpha);
+ border-color: transparent;
+ color: var(--color-warning);
+}
+
+.topics-rates {
+ font-family: var(--font-mono, monospace);
+ font-size: 11px;
+ white-space: nowrap;
+ cursor: help;
+}
+
+.topics-rates .rate-sep {
+ margin: 0 3px;
+ color: var(--color-text-tertiary);
+}
+
.actions {
display: flex;
gap: 6px;
diff --git a/apps/desktop/src/components/mq/__tests__/MonitoringPanel.spec.ts b/apps/desktop/src/components/mq/__tests__/MonitoringPanel.spec.ts
index 23e978f6e7..daa98a5b24 100644
--- a/apps/desktop/src/components/mq/__tests__/MonitoringPanel.spec.ts
+++ b/apps/desktop/src/components/mq/__tests__/MonitoringPanel.spec.ts
@@ -21,7 +21,13 @@ vi.mock("echarts/charts", () => ({ LineChart: {} }));
vi.mock("echarts/components", () => ({ GridComponent: {}, LegendComponent: {}, TooltipComponent: {} }));
vi.mock("vue-echarts", async () => {
const { defineComponent, h } = await import("vue");
- return { default: defineComponent({ name: "VChart", setup: () => () => h("div") }) };
+ return {
+ default: defineComponent({
+ name: "VChart",
+ props: { option: { type: Object, required: true } },
+ setup: (props) => () => h("div", { "data-chart-option": JSON.stringify(props.option) }),
+ }),
+ };
});
vi.mock("@lucide/vue", async () => {
const { defineComponent, h } = await import("vue");
@@ -89,15 +95,15 @@ async function flushUi() {
await nextTick();
}
-async function mountPanel() {
+async function mountPanel(options: { mqSystemKind?: "kafka" | "rabbitmq"; tenant?: string; namespace?: string } = {}) {
root = document.createElement("div");
document.body.appendChild(root);
app = createApp(MonitoringPanel, {
connectionId: "mq-1",
- tenant: "_kafka",
- namespace: "default",
+ tenant: options.tenant ?? "_kafka",
+ namespace: options.namespace ?? "default",
topic: TOPIC,
- mqSystemKind: "kafka",
+ mqSystemKind: options.mqSystemKind ?? "kafka",
onNavigateTab: navigateTab,
});
app.mount(root);
@@ -189,3 +195,52 @@ describe("MonitoringPanel Kafka message browser", () => {
}
});
});
+
+describe("MonitoringPanel unavailable RabbitMQ rates", () => {
+ it("renders no-data without plotting zeros or reporting an idle flow", async () => {
+ backend.mqGetTopicStats.mockResolvedValue({
+ ...KAFKA_STATS,
+ ratesUnavailable: true,
+ raw: {},
+ });
+ backend.mqGetBacklog.mockResolvedValue({ msgBacklog: 5, backlogSize: 128 });
+
+ const panel = await mountPanel({ mqSystemKind: "rabbitmq", tenant: "_rabbitmq", namespace: "/" });
+
+ expect(panel.querySelector<HTMLElement>('[data-testid="monitoring-rate-in"]')?.textContent?.trim()).toBe("-");
+ expect(panel.querySelector<HTMLElement>('[data-testid="monitoring-rate-out"]')?.textContent?.trim()).toBe("-");
+ const flowStatus = panel.querySelector<HTMLElement>('[data-testid="monitoring-flow-status"]');
+ expect(flowStatus?.textContent?.trim()).toBe("-");
+ expect(flowStatus?.classList.contains("idle")).toBe(false);
+ expect(flowStatus?.classList.contains("unavailable")).toBe(true);
+
+ const rateChart = panel.querySelector<HTMLElement>('[data-testid="monitoring-rate-chart"]');
+ const option = JSON.parse(rateChart?.dataset.chartOption ?? "{}");
+ expect(option.series[0].data).toEqual([null]);
+ expect(option.series[1].data).toEqual([null]);
+ expect(backend.mqGetTopicStats).toHaveBeenCalledTimes(1);
+ expect(backend.mqGetBacklog).toHaveBeenCalledTimes(1);
+ });
+
+ it("keeps a sampled zero as a real idle rate", async () => {
+ backend.mqGetTopicStats.mockResolvedValue({
+ ...KAFKA_STATS,
+ ratesUnavailable: false,
+ raw: {},
+ });
+ backend.mqGetBacklog.mockResolvedValue({ msgBacklog: 0, backlogSize: 0 });
+
+ const panel = await mountPanel({ mqSystemKind: "rabbitmq", tenant: "_rabbitmq", namespace: "/" });
+
+ expect(panel.querySelector<HTMLElement>('[data-testid="monitoring-rate-in"]')?.textContent?.trim()).toBe("0.00 msg/s");
+ expect(panel.querySelector<HTMLElement>('[data-testid="monitoring-rate-out"]')?.textContent?.trim()).toBe("0.00 msg/s");
+ const flowStatus = panel.querySelector<HTMLElement>('[data-testid="monitoring-flow-status"]');
+ expect(flowStatus?.textContent?.trim()).toBe("mqMonitoring.flowIdle");
+ expect(flowStatus?.classList.contains("idle")).toBe(true);
+
+ const rateChart = panel.querySelector<HTMLElement>('[data-testid="monitoring-rate-chart"]');
+ const option = JSON.parse(rateChart?.dataset.chartOption ?? "{}");
+ expect(option.series[0].data).toEqual([0]);
+ expect(option.series[1].data).toEqual([0]);
+ });
+});
diff --git a/apps/desktop/src/components/mq/__tests__/TopicsPanel.spec.ts b/apps/desktop/src/components/mq/__tests__/TopicsPanel.spec.ts
index bfd0661996..f6bfb2cc3f 100644
--- a/apps/desktop/src/components/mq/__tests__/TopicsPanel.spec.ts
+++ b/apps/desktop/src/components/mq/__tests__/TopicsPanel.spec.ts
@@ -84,6 +84,21 @@ async function mountRabbitMqPanel() {
return root;
}
+async function mountRabbitMqAllVhostsPanel() {
+ root = document.createElement("div");
+ document.body.appendChild(root);
+ app = createApp(TopicsPanel, {
+ connectionId: "rabbit-1",
+ tenant: "_rabbitmq",
+ namespace: "*",
+ mqSystemKind: "rabbitmq",
+ supportsExchanges: true,
+ });
+ app.mount(root);
+ await flushUi();
+ return root;
+}
+
function rowNames(container: ParentNode): string[] {
return [...container.querySelectorAll<HTMLElement>(".topic-name-text")].map((item) => item.textContent ?? "");
}
@@ -91,8 +106,34 @@ function rowNames(container: ParentNode): string[] {
beforeEach(() => {
Object.values(backend).forEach((mock) => mock.mockReset());
backend.mqListTopics.mockResolvedValue([
- { name: "alpha", shortName: "alpha", partitioned: false, persistent: true, messageCount: 4, messagesReady: 3, messagesUnacked: 1 },
- { name: "beta", shortName: "beta", partitioned: false, persistent: true, messageCount: 12, messagesReady: 12, messagesUnacked: 0 },
+ {
+ name: "alpha",
+ shortName: "alpha",
+ partitioned: false,
+ persistent: true,
+ messageCount: 4,
+ messagesReady: 3,
+ messagesUnacked: 1,
+ queueType: "quorum",
+ state: "running",
+ autoDelete: true,
+ consumerCount: 2,
+ arguments: { "x-queue-type": "quorum", "x-message-ttl": 60000, "x-dead-letter-exchange": "dlx" },
+ publishRate: 12.5,
+ deliverRate: 11.8,
+ ackRate: 11.2,
+ },
+ {
+ name: "beta",
+ shortName: "beta",
+ partitioned: false,
+ persistent: true,
+ messageCount: 12,
+ messagesReady: 12,
+ messagesUnacked: 0,
+ // No queue type, no arguments, and no message_stats sample:
+ // type stays unknown, rates render as "-" (never fabricated zeros).
+ },
]);
});
@@ -121,4 +162,58 @@ describe("TopicsPanel RabbitMQ queue messages", () => {
await nextTick();
expect(rowNames(panel)).toEqual(["alpha", "beta"]);
});
+
+ it("shows queue type, state, features, consumers and message rates", async () => {
+ const panel = await mountRabbitMqPanel();
+
+ const rows = [...panel.querySelectorAll<HTMLElement>(".topic-name-text")].map((name) => name.closest(".topics-row"));
+ const alpha = rows[0];
+ if (!alpha) throw new Error("alpha row not found");
+
+ // Queue type badge + state label.
+ const typeCell = alpha.querySelector<HTMLElement>(".badge");
+ expect(typeCell?.textContent?.trim()).toBe("quorum");
+ expect(alpha.querySelector<HTMLElement>(".queue-state")?.textContent?.trim()).toBe("running");
+
+ // Compact feature badges: D (durable) + AD (auto-delete) + TTL + DLX.
+ const featureBadges = [...alpha.querySelectorAll<HTMLElement>('[data-testid="rabbitmq-features"] .feature-badge')].map((item) => item.textContent?.trim());
+ expect(featureBadges).toEqual(["D", "AD", "TTL", "DLX"]);
+
+ // Consumers column.
+ expect(alpha.querySelector<HTMLElement>('[data-testid="rabbitmq-consumers"]')?.textContent?.trim()).toBe("2");
+
+ // Rates: publish / deliver / ack.
+ expect(alpha.querySelector<HTMLElement>('[data-testid="rabbitmq-rates"]')?.textContent?.trim()).toBe("12.50/11.80/11.20");
+ });
+
+ it("renders missing queue data as unknown type and dashed rates, never as zeros", async () => {
+ const panel = await mountRabbitMqPanel();
+
+ const rows = [...panel.querySelectorAll<HTMLElement>(".topic-name-text")].map((name) => name.closest(".topics-row"));
+ const beta = rows[1];
+ if (!beta) throw new Error("beta row not found");
+
+ // No type and no x-queue-type: the label must not guess "classic".
+ expect(beta.querySelector<HTMLElement>(".badge")?.textContent?.trim()).toBe("mqTopics.rabbitmqQueueTypeUnknown");
+
+ // Durable remains visible; consumers and rates have no sample.
+ expect(beta.querySelector<HTMLElement>('[data-testid="rabbitmq-features"]')?.textContent?.trim()).toBe("D");
+ expect(beta.querySelector<HTMLElement>('[data-testid="rabbitmq-consumers"]')?.textContent?.trim()).toBe("-");
+ expect(beta.querySelector<HTMLElement>('[data-testid="rabbitmq-rates"]')?.textContent?.trim()).toBe("-/-/-");
+ });
+
+ it("keeps per-queue vhosts separate in all-vhosts mode (#5984 regression guard)", async () => {
+ backend.mqListTopics.mockResolvedValue([
+ { name: "orders", shortName: "orders", partitioned: false, persistent: true, namespace: "/", messageCount: 3, messagesReady: 3 },
+ { name: "orders", shortName: "orders", partitioned: false, persistent: true, namespace: "/staging", messageCount: 7, messagesReady: 7 },
+ ]);
+ const panel = await mountRabbitMqAllVhostsPanel();
+
+ // Both rows are named "orders" but must stay distinct per virtual host;
+ // the namespace column shows each queue's own vhost.
+ const namespaceCells = [...panel.querySelectorAll<HTMLElement>(".topics-row .topics-col:nth-child(2)")].map((item) => item.textContent?.trim());
+ expect(namespaceCells).toEqual(["/", "/staging"]);
+ const counts = [...panel.querySelectorAll<HTMLElement>('[data-testid="rabbitmq-message-count"]')].map((item) => item.textContent?.trim());
+ expect(counts).toEqual(["3", "7"]);
+ });
});
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 74d5353293..7929f88b03 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -6819,6 +6819,18 @@ export default {
beginOffset: "Min offset",
endOffset: "Max offset",
messageCount: "Messages",
+ // RabbitMQ queue table columns (issue #6600)
+ rabbitmqQueueType: "Type",
+ rabbitmqQueueTypeHint: "Queue type reported by the management API (type or x-queue-type); classic / quorum / stream",
+ rabbitmqQueueTypeUnknown: "Queue",
+ rabbitmqFeatures: "Features",
+ rabbitmqState: "State",
+ rabbitmqArguments: "Arguments",
+ consumers: "Consumers",
+ rabbitmqRates: "Rates",
+ rabbitmqPublishRate: "Publish",
+ rabbitmqDeliverRate: "Deliver/Get",
+ rabbitmqAckRate: "Ack",
},
mqExchanges: {
searchPlaceholder: "Search exchanges",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 7e8b1746e7..9ff6df759e 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -6949,6 +6949,17 @@ export default withEnglishFallback({
beginOffset: "Offset mínimo",
endOffset: "Offset máximo",
messageCount: "Número de mensajes",
+ rabbitmqQueueType: "Tipo",
+ rabbitmqQueueTypeHint: "Tipo de cola reportado por la API de gestión (type o x-queue-type): classic / quorum / stream",
+ rabbitmqQueueTypeUnknown: "Cola",
+ rabbitmqFeatures: "Funciones",
+ rabbitmqState: "Estado",
+ rabbitmqArguments: "Argumentos",
+ consumers: "Consumidores",
+ rabbitmqRates: "Velocidades",
+ rabbitmqPublishRate: "Publicar",
+ rabbitmqDeliverRate: "Entrega/Obtención",
+ rabbitmqAckRate: "Acuse",
},
mqAdmin: {
viewTenant: "Ver tenant",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 013f8e93f0..7bedbb4daf 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -6949,6 +6949,17 @@ export default withEnglishFallback({
beginOffset: "Offset minimo",
endOffset: "Offset massimo",
messageCount: "Numero di messaggi",
+ rabbitmqQueueType: "Tipo",
+ rabbitmqQueueTypeHint: "Tipo di coda riportato dall'API di gestione (type o x-queue-type): classic / quorum / stream",
+ rabbitmqQueueTypeUnknown: "Coda",
+ rabbitmqFeatures: "Funzionalità",
+ rabbitmqState: "Stato",
+ rabbitmqArguments: "Argomenti",
+ consumers: "Consumatori",
+ rabbitmqRates: "Velocità",
+ rabbitmqPublishRate: "Pubblica",
+ rabbitmqDeliverRate: "Consegna/Recupero",
+ rabbitmqAckRate: "Ack",
},
mqAdmin: {
viewTenant: "Visualizza tenant",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index d4d4313b58..6f8b68f8b0 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -7002,6 +7002,17 @@ export default withEnglishFallback({
beginOffset: "最小 Offset",
endOffset: "最大 Offset",
messageCount: "メッセージ数",
+ rabbitmqQueueType: "種類",
+ rabbitmqQueueTypeHint: "Management API が報告するキュータイプ(type または x-queue-type):classic / quorum / stream",
+ rabbitmqQueueTypeUnknown: "キュー",
+ rabbitmqFeatures: "機能",
+ rabbitmqState: "状態",
+ rabbitmqArguments: "引数",
+ consumers: "コンシューマー",
+ rabbitmqRates: "レート",
+ rabbitmqPublishRate: "公開",
+ rabbitmqDeliverRate: "配信/取得",
+ rabbitmqAckRate: "応答",
},
mqAdmin: {
viewTenant: "テナントを表示",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index b42820ea19..b44901e160 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -6230,6 +6230,17 @@ export default withEnglishFallback({
beginOffset: "최소 오프셋",
endOffset: "최대 오프셋",
messageCount: "메시지",
+ rabbitmqQueueType: "유형",
+ rabbitmqQueueTypeHint: "Management API가 보고한 큐 유형(type 또는 x-queue-type): classic / quorum / stream",
+ rabbitmqQueueTypeUnknown: "큐",
+ rabbitmqFeatures: "기능",
+ rabbitmqState: "상태",
+ rabbitmqArguments: "인수",
+ consumers: "소비자",
+ rabbitmqRates: "전송률",
+ rabbitmqPublishRate: "게시",
+ rabbitmqDeliverRate: "전달/획득",
+ rabbitmqAckRate: "ACK",
},
mqExchanges: {
searchPlaceholder: "익스체인지 검색",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index ed65889b8f..7d1e6d9503 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -6951,6 +6951,17 @@ export default withEnglishFallback({
beginOffset: "Offset mínimo",
endOffset: "Offset máximo",
messageCount: "Número de mensagens",
+ rabbitmqQueueType: "Tipo",
+ rabbitmqQueueTypeHint: "Tipo de fila relatado pela API de gerenciamento (type ou x-queue-type): classic / quorum / stream",
+ rabbitmqQueueTypeUnknown: "Fila",
+ rabbitmqFeatures: "Recursos",
+ rabbitmqState: "Estado",
+ rabbitmqArguments: "Argumentos",
+ consumers: "Consumidores",
+ rabbitmqRates: "Taxas",
+ rabbitmqPublishRate: "Publicar",
+ rabbitmqDeliverRate: "Entrega/Obtenção",
+ rabbitmqAckRate: "Ack",
},
mqAdmin: {
viewTenant: "Ver locatário",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 0625a3813f..aa800a6878 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -6804,6 +6804,18 @@ export default withEnglishFallback({
beginOffset: "最小 Offset",
endOffset: "最大 Offset",
messageCount: "消息数",
+ // RabbitMQ 队列表格列(issue #6600)
+ rabbitmqQueueType: "类型",
+ rabbitmqQueueTypeHint: "Management API 报告的队列类型(type 或 x-queue-type):classic / quorum / stream",
+ rabbitmqQueueTypeUnknown: "队列",
+ rabbitmqFeatures: "特性",
+ rabbitmqState: "状态",
+ rabbitmqArguments: "参数",
+ consumers: "消费者",
+ rabbitmqRates: "速率",
+ rabbitmqPublishRate: "发布",
+ rabbitmqDeliverRate: "投递/获取",
+ rabbitmqAckRate: "确认",
},
mqExchanges: {
searchPlaceholder: "搜索交换机",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index a342b3f39c..1cff1c284d 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -6942,6 +6942,17 @@ export default withEnglishFallback({
beginOffset: "最小 Offset",
endOffset: "最大 Offset",
messageCount: "消息數",
+ rabbitmqQueueType: "類型",
+ rabbitmqQueueTypeHint: "Management API 回報的佇列類型(type 或 x-queue-type):classic / quorum / stream",
+ rabbitmqQueueTypeUnknown: "佇列",
+ rabbitmqFeatures: "功能",
+ rabbitmqState: "狀態",
+ rabbitmqArguments: "參數",
+ consumers: "消費者",
+ rabbitmqRates: "速率",
+ rabbitmqPublishRate: "發布",
+ rabbitmqDeliverRate: "投遞/擷取",
+ rabbitmqAckRate: "確認",
},
mqAdmin: {
viewTenant: "檢視租用戶",
diff --git a/apps/desktop/src/lib/mq/__tests__/rabbitmqQueueFeatures.spec.ts b/apps/desktop/src/lib/mq/__tests__/rabbitmqQueueFeatures.spec.ts
new file mode 100644
index 0000000000..97cd356ab2
--- /dev/null
+++ b/apps/desktop/src/lib/mq/__tests__/rabbitmqQueueFeatures.spec.ts
@@ -0,0 +1,97 @@
+import { describe, expect, it } from "vitest";
+import { formatMqRate, rabbitMqArgumentText, rabbitMqArgumentsSummary, rabbitMqFeatureBadges, rabbitMqHasUnknownArguments, rabbitMqQueueType } from "@/lib/mq/rabbitmqQueueFeatures";
+import type { TopicInfo } from "@/types/mq";
+
+function topic(partial: Partial<TopicInfo>): TopicInfo {
+ return { name: "q", shortName: "q", partitioned: false, persistent: true, ...partial };
+}
+
+describe("rabbitMqFeatureBadges", () => {
+ it("maps durability flags and known x-arguments to compact badges", () => {
+ const badges = rabbitMqFeatureBadges(
+ topic({
+ autoDelete: true,
+ exclusive: true,
+ arguments: {
+ "x-queue-type": "quorum",
+ "x-message-ttl": 60000,
+ "x-dead-letter-exchange": "dlx",
+ },
+ }),
+ );
+
+ expect(badges.map((badge) => badge.label)).toEqual(["D", "AD", "EX", "TTL", "DLX"]);
+ expect(badges.find((badge) => badge.label === "D")?.title).toBe("Durable");
+ expect(badges.find((badge) => badge.label === "TTL")?.title).toBe("x-message-ttl: 60000");
+ });
+
+ it("keeps unknown x-arguments in an Args count badge with full details", () => {
+ const badges = rabbitMqFeatureBadges(
+ topic({
+ arguments: { "x-message-ttl": 100, "x-new-feature": true, "x-other": { nested: [1, 2] } },
+ }),
+ );
+
+ const argsBadge = badges.find((badge) => badge.key === "args");
+ expect(argsBadge?.label).toBe("2A");
+ expect(argsBadge?.title).toContain("x-new-feature: true");
+ expect(argsBadge?.title).toContain('x-other: {"nested":[1,2]}');
+ });
+
+ it("returns no badges for a plain queue", () => {
+ expect(rabbitMqFeatureBadges(topic({ persistent: false }))).toEqual([]);
+ });
+
+ it("preserves argument value types in tooltips", () => {
+ expect(rabbitMqArgumentText(60000)).toBe("60000");
+ expect(rabbitMqArgumentText(true)).toBe("true");
+ expect(rabbitMqArgumentText(null)).toBe("null");
+ expect(rabbitMqArgumentText({ nested: 1 })).toBe('{"nested":1}');
+ });
+});
+
+describe("rabbitMqArgumentsSummary", () => {
+ it("joins sorted key/value pairs", () => {
+ const summary = rabbitMqArgumentsSummary(topic({ arguments: { "x-max-length": 10, "x-message-ttl": 5 } }));
+ expect(summary).toBe("x-max-length: 10 · x-message-ttl: 5");
+ });
+
+ it("returns undefined without arguments", () => {
+ expect(rabbitMqArgumentsSummary(topic({}))).toBeUndefined();
+ });
+});
+
+describe("rabbitMqQueueType", () => {
+ it("prefers the explicit type field", () => {
+ expect(rabbitMqQueueType(topic({ queueType: "quorum", arguments: { "x-queue-type": "stream" } }))).toBe("quorum");
+ });
+
+ it("falls back to the x-queue-type argument for older brokers", () => {
+ expect(rabbitMqQueueType(topic({ arguments: { "x-queue-type": "stream" } }))).toBe("stream");
+ });
+
+ it("never guesses classic when the type is unknown", () => {
+ expect(rabbitMqQueueType(topic({}))).toBeUndefined();
+ });
+});
+
+describe("formatMqRate", () => {
+ it("renders a sampled rate with two decimals", () => {
+ expect(formatMqRate(12.5)).toBe("12.50/s");
+ });
+
+ it("renders a genuine zero rate as zero, not as no-data", () => {
+ expect(formatMqRate(0)).toBe("0.00/s");
+ });
+
+ it("renders missing data as a dash, never as a fabricated zero", () => {
+ expect(formatMqRate(undefined)).toBe("-");
+ });
+});
+
+describe("rabbitMqHasUnknownArguments", () => {
+ it("flags unknown arguments", () => {
+ expect(rabbitMqHasUnknownArguments(topic({ arguments: { "x-brand-new": 1 } }))).toBe(true);
+ expect(rabbitMqHasUnknownArguments(topic({ arguments: { "x-message-ttl": 1 } }))).toBe(false);
+ });
+});
diff --git a/apps/desktop/src/lib/mq/rabbitmqQueueFeatures.ts b/apps/desktop/src/lib/mq/rabbitmqQueueFeatures.ts
new file mode 100644
index 0000000000..9d7b69d01e
--- /dev/null
+++ b/apps/desktop/src/lib/mq/rabbitmqQueueFeatures.ts
@@ -0,0 +1,138 @@
+import type { TopicInfo } from "@/types/mq";
+
+/**
+ * Compact RabbitMQ queue feature badge shown in the queues table.
+ * `label` is the terse badge text (e.g. "TTL", "DLX"); `title` is the
+ * full tooltip (argument name + value); `kind` drives the badge color.
+ */
+export interface RabbitMqFeatureBadge {
+ key: string;
+ kind: "feature" | "argument";
+ label: string;
+ title: string;
+}
+
+/** Arguments with dedicated compact badges; everything else folds into the "Args" count. */
+const KNOWN_ARGUMENT_BADGES: ReadonlyArray<{ key: string; label: string }> = [
+ { key: "x-message-ttl", label: "TTL" },
+ { key: "x-expires", label: "EXP" },
+ { key: "x-max-length", label: "ML" },
+ { key: "x-max-length-bytes", label: "MB" },
+ { key: "x-max-priority", label: "MP" },
+ { key: "x-dead-letter-exchange", label: "DLX" },
+ { key: "x-dead-letter-routing-key", label: "DLK" },
+ { key: "x-single-active-consumer", label: "SAC" },
+ { key: "x-queue-mode", label: "QM" },
+ { key: "x-queue-master-locator", label: "QML" },
+];
+
+const KNOWN_ARGUMENT_KEYS: ReadonlySet<string> = new Set([
+ // Badged arguments.
+ ...KNOWN_ARGUMENT_BADGES.map((entry) => entry.key),
+ // Queue type is displayed in its own column, never as a feature badge.
+ "x-queue-type",
+]);
+
+/** Render an argument value for tooltips without dropping its type. */
+export function rabbitMqArgumentText(value: unknown): string {
+ if (value === null) return "null";
+ if (typeof value === "object") {
+ try {
+ return JSON.stringify(value);
+ } catch {
+ return String(value);
+ }
+ }
+ return String(value);
+}
+
+/**
+ * Build the compact feature badges for a RabbitMQ queue row: durability flags
+ * plus the interesting x-arguments. Unknown / future arguments are never
+ * dropped — they fold into an "Args" count badge so new features keep
+ * surfacing without hard-coding them into the UI.
+ */
+export function rabbitMqFeatureBadges(topic: Pick<TopicInfo, "persistent" | "autoDelete" | "exclusive" | "arguments">): RabbitMqFeatureBadge[] {
+ const badges: RabbitMqFeatureBadge[] = [];
+ if (topic.persistent) {
+ badges.push({ key: "durable", kind: "feature", label: "D", title: "Durable" });
+ }
+ if (topic.autoDelete) {
+ badges.push({ key: "autoDelete", kind: "feature", label: "AD", title: "Auto-delete" });
+ }
+ if (topic.exclusive) {
+ badges.push({ key: "exclusive", kind: "feature", label: "EX", title: "Exclusive" });
+ }
+ const argumentsMap = topic.arguments ?? {};
+ const extraKeys: string[] = [];
+ for (const [key, value] of Object.entries(argumentsMap)) {
+ const known = KNOWN_ARGUMENT_BADGES.find((entry) => entry.key === key);
+ if (known) {
+ badges.push({
+ key: `arg:${key}`,
+ kind: "argument",
+ label: known.label,
+ title: `${key}: ${rabbitMqArgumentText(value)}`,
+ });
+ } else if (!KNOWN_ARGUMENT_KEYS.has(key)) {
+ extraKeys.push(key);
+ }
+ }
+ if (extraKeys.length > 0) {
+ badges.push({
+ key: "args",
+ kind: "argument",
+ label: `${extraKeys.length}A`,
+ title: extraKeys.map((key) => `${key}: ${rabbitMqArgumentText(argumentsMap[key])}`).join(" · "),
+ });
+ }
+ return badges;
+}
+
+/**
+ * Full arguments summary for the row tooltip, e.g.
+ * "x-message-ttl: 60000 · x-max-length: 1000". Returns undefined when the
+ * queue has no arguments at all.
+ */
+export function rabbitMqArgumentsSummary(topic: Pick<TopicInfo, "arguments">): string | undefined {
+ const argumentsMap = topic.arguments;
+ if (!argumentsMap || Object.keys(argumentsMap).length === 0) return undefined;
+ return Object.entries(argumentsMap)
+ .sort(([left], [right]) => left.localeCompare(right))
+ .map(([key, value]) => `${key}: ${rabbitMqArgumentText(value)}`)
+ .join(" · ");
+}
+
+/** Whether any x-argument is unknown to the current UI — signals new features. */
+export function rabbitMqHasUnknownArguments(topic: Pick<TopicInfo, "arguments">): boolean {
+ const argumentsMap = topic.arguments ?? {};
+ return Object.keys(argumentsMap).some((key) => !KNOWN_ARGUMENT_KEYS.has(key));
+}
+
+/**
+ * RabbitMQ queue type for display. Prefers the management API's `type` field,
+ * falls back to the x-queue-type argument, and never guesses "classic" when
+ * neither is present.
+ */
+export function rabbitMqQueueType(topic: Pick<TopicInfo, "queueType" | "arguments">): string | undefined {
+ if (topic.queueType) return topic.queueType;
+ const argumentType = topic.arguments?.["x-queue-type"];
+ return typeof argumentType === "string" && argumentType.trim() ? argumentType.trim() : undefined;
+}
+
+/**
+ * Format a message rate for display. `undefined` (the management API sampled
+ * no message_stats) renders as "-" — distinct from a genuine sampled rate of
+ * zero, which renders as "0.00/s".
+ */
+export function formatMqRate(value: number | undefined): string {
+ return value === undefined ? "-" : `${value.toFixed(2)}/s`;
+}
+
+/**
+ * Compact per-cell rate value (no unit) for the queues table; the column
+ * header carries the unit. Missing data renders as "-".
+ */
+export function formatMqRateCompact(value: number | undefined): string {
+ return value === undefined ? "-" : value.toFixed(2);
+}
diff --git a/apps/desktop/src/types/mq.ts b/apps/desktop/src/types/mq.ts
index 0b4a787a64..082c718dd5 100644
--- a/apps/desktop/src/types/mq.ts
+++ b/apps/desktop/src/types/mq.ts
@@ -162,6 +162,24 @@ export interface TopicInfo {
messagesReady?: number;
/** RabbitMQ messages delivered but not yet acknowledged. */
messagesUnacked?: number;
+ /** RabbitMQ queue: auto-delete flag. */
+ autoDelete?: boolean;
+ /** RabbitMQ queue: exclusive flag. */
+ exclusive?: boolean;
+ /** RabbitMQ queue: state (running / idle / flow / blocked ...). */
+ state?: string;
+ /** RabbitMQ queue: type (classic / quorum / stream), from the management API `type` field or x-queue-type. */
+ queueType?: string;
+ /** RabbitMQ queue: x-arguments preserving the original JSON value types. */
+ arguments?: Record<string, unknown>;
+ /** RabbitMQ queue: consumer count. */
+ consumerCount?: number;
+ /** RabbitMQ queue: publish rate (msg/s) when the management API sampled message_stats. */
+ publishRate?: number;
+ /** RabbitMQ queue: deliver/get rate (msg/s). */
+ deliverRate?: number;
+ /** RabbitMQ queue: ack rate (msg/s). */
+ ackRate?: number;
}
export interface ListTopicsOpts {
@@ -179,6 +197,8 @@ export interface TopicStats {
msgOutCounter: number;
subscriptionCount: number;
producerCount: number;
+ /** RabbitMQ: true when the management API exposed no message_stats sample, so msgRateIn/Out must be rendered as "no data" rather than a real rate of 0. */
+ ratesUnavailable?: boolean;
raw?: unknown;
}
diff --git a/crates/dbx-core/src/mq/adapters/kafka.rs b/crates/dbx-core/src/mq/adapters/kafka.rs
index 14f550b090..e1238465f6 100644
--- a/crates/dbx-core/src/mq/adapters/kafka.rs
+++ b/crates/dbx-core/src/mq/adapters/kafka.rs
@@ -209,6 +209,7 @@ impl MessageQueueAdmin for KafkaAdmin {
message_count: None,
messages_ready: None,
messages_unacked: None,
+ ..Default::default()
}
})
.collect())
@@ -256,6 +257,7 @@ impl MessageQueueAdmin for KafkaAdmin {
msg_out_counter: 0,
subscription_count: 0,
producer_count: 0,
+ rates_unavailable: false,
raw: result,
})
}
diff --git a/crates/dbx-core/src/mq/adapters/pulsar.rs b/crates/dbx-core/src/mq/adapters/pulsar.rs
index cac27425a4..3cf99d54e5 100644
--- a/crates/dbx-core/src/mq/adapters/pulsar.rs
+++ b/crates/dbx-core/src/mq/adapters/pulsar.rs
@@ -300,6 +300,7 @@ impl MessageQueueAdmin for PulsarAdmin {
message_count: None,
messages_ready: None,
messages_unacked: None,
+ ..Default::default()
})
})
.buffered(PARTITION_METADATA_CONCURRENCY)
@@ -329,6 +330,7 @@ impl MessageQueueAdmin for PulsarAdmin {
message_count: None,
messages_ready: None,
messages_unacked: None,
+ ..Default::default()
});
}
}
@@ -1606,6 +1608,7 @@ mod tests {
msg_out_counter: 0,
subscription_count: 2,
producer_count: 0,
+ rates_unavailable: false,
raw: serde_json::json!({
"subscriptions": {
"sub-a": { "msgBacklog": 7 },
diff --git a/crates/dbx-core/src/mq/adapters/pulsar_version.rs b/crates/dbx-core/src/mq/adapters/pulsar_version.rs
index 8f4ad136d2..f15d9426dd 100644
--- a/crates/dbx-core/src/mq/adapters/pulsar_version.rs
+++ b/crates/dbx-core/src/mq/adapters/pulsar_version.rs
@@ -353,6 +353,7 @@ impl PulsarApiProfile {
msg_out_counter: i64_of("msgOutCounter"),
subscription_count,
producer_count,
+ rates_unavailable: false,
raw: raw.clone(),
}
}
diff --git a/crates/dbx-core/src/mq/adapters/rabbitmq.rs b/crates/dbx-core/src/mq/adapters/rabbitmq.rs
index 956484a38e..be4e665e89 100644
--- a/crates/dbx-core/src/mq/adapters/rabbitmq.rs
+++ b/crates/dbx-core/src/mq/adapters/rabbitmq.rs
@@ -212,23 +212,7 @@ impl MessageQueueAdmin for RabbitMqAdmin {
require_specific_vhost(&topic.namespace)?;
let params = with_virtual_host(serde_json::json!({ "name": queue_name(topic) }), &topic.namespace);
let result: serde_json::Value = self.call("mq_get_topic_stats", params).await?;
-
- let total_messages = result.get("totalMessages").and_then(|v| v.as_i64()).unwrap_or(0);
- let consumer_count = result.get("consumerCount").and_then(|v| v.as_u64()).unwrap_or(0) as u32;
-
- Ok(TopicStats {
- msg_rate_in: 0.0,
- msg_rate_out: 0.0,
- msg_throughput_in: 0.0,
- msg_throughput_out: 0.0,
- storage_size: 0,
- backlog_size: total_messages,
- msg_in_counter: 0,
- msg_out_counter: 0,
- subscription_count: consumer_count,
- producer_count: 0,
- raw: result,
- })
+ Ok(topic_stats_from_agent_value(result))
}
async fn get_topic_internal_stats(&self, topic: &TopicRef) -> Result<serde_json::Value, String> {
@@ -997,8 +981,45 @@ fn peeked_message_from_json(idx: usize, m: &serde_json::Value) -> PeekedMessage
}
}
+/// Map an `mq_get_topic_stats` agent payload onto the UI-friendly TopicStats.
+///
+/// RabbitMQ rates come from the management API's `message_stats` sample. A
+/// missing sample (new/idle queue, rates_mode=basic/none, or the AMQP
+/// passive-declare fallback path) must NOT be presented as a real rate of
+/// zero: `rates_unavailable` is set so the UI renders "no data" instead.
+fn topic_stats_from_agent_value(result: serde_json::Value) -> TopicStats {
+ let total_messages = result.get("totalMessages").and_then(|v| v.as_i64()).unwrap_or(0);
+ let consumer_count = result.get("consumerCount").and_then(|v| v.as_u64()).unwrap_or(0) as u32;
+ let publish_rate = result.get("publishRate").and_then(|v| v.as_f64());
+ let deliver_rate = result.get("deliverRate").and_then(|v| v.as_f64());
+ let has_stats =
+ result.get("publishRate").is_some() || result.get("deliverRate").is_some() || result.get("ackRate").is_some();
+
+ TopicStats {
+ msg_rate_in: publish_rate.unwrap_or(0.0),
+ msg_rate_out: deliver_rate.unwrap_or(0.0),
+ msg_throughput_in: 0.0,
+ msg_throughput_out: 0.0,
+ storage_size: 0,
+ backlog_size: total_messages,
+ msg_in_counter: result.get("publishTotal").and_then(|v| v.as_i64()).unwrap_or(0),
+ msg_out_counter: result.get("deliverGetTotal").and_then(|v| v.as_i64()).unwrap_or(0),
+ subscription_count: consumer_count,
+ producer_count: 0,
+ rates_unavailable: !has_stats,
+ raw: result,
+ }
+}
+
fn topic_info_from_agent_value(topic: &serde_json::Value) -> TopicInfo {
let name = topic.get("name").and_then(|value| value.as_str()).unwrap_or_default().to_string();
+ // Older RabbitMQ versions only report the queue type in the x-queue-type
+ // argument; the agent already prefers the explicit `type` field.
+ let queue_type = topic
+ .get("queueType")
+ .and_then(|value| value.as_str())
+ .or_else(|| topic.get("arguments").and_then(|args| args.get("x-queue-type")).and_then(|value| value.as_str()))
+ .map(String::from);
TopicInfo {
name: name.clone(),
short_name: name,
@@ -1012,6 +1033,15 @@ fn topic_info_from_agent_value(topic: &serde_json::Value) -> TopicInfo {
message_count: topic.get("messages").and_then(|value| value.as_i64()),
messages_ready: topic.get("messagesReady").and_then(|value| value.as_i64()),
messages_unacked: topic.get("messagesUnacked").and_then(|value| value.as_i64()),
+ auto_delete: topic.get("autoDelete").and_then(|value| value.as_bool()),
+ exclusive: topic.get("exclusive").and_then(|value| value.as_bool()),
+ state: topic.get("state").and_then(|value| value.as_str()).map(String::from),
+ queue_type,
+ arguments: topic.get("arguments").cloned().filter(|value| !value.is_null()),
+ consumer_count: topic.get("consumerCount").or_else(|| topic.get("consumers")).and_then(|value| value.as_i64()),
+ publish_rate: topic.get("publishRate").and_then(|value| value.as_f64()),
+ deliver_rate: topic.get("deliverRate").and_then(|value| value.as_f64()),
+ ack_rate: topic.get("ackRate").and_then(|value| value.as_f64()),
}
}
@@ -1207,6 +1237,129 @@ mod tests {
assert_eq!(topic.namespace.as_deref(), Some("/"));
}
+ #[test]
+ fn topic_info_maps_queue_features_arguments_and_rates() {
+ let topic = topic_info_from_agent_value(&serde_json::json!({
+ "name": "orders",
+ "durable": true,
+ "autoDelete": false,
+ "exclusive": true,
+ "state": "running",
+ "queueType": "quorum",
+ "consumerCount": 4,
+ "arguments": {
+ "x-queue-type": "quorum",
+ "x-message-ttl": 60000,
+ "x-max-length": 1000
+ },
+ "publishRate": 12.5,
+ "deliverRate": 11.8,
+ "ackRate": 11.2
+ }));
+
+ assert_eq!(topic.auto_delete, Some(false));
+ assert_eq!(topic.exclusive, Some(true));
+ assert_eq!(topic.state.as_deref(), Some("running"));
+ assert_eq!(topic.queue_type.as_deref(), Some("quorum"));
+ assert_eq!(topic.consumer_count, Some(4));
+ assert_eq!(topic.publish_rate, Some(12.5));
+ assert_eq!(topic.deliver_rate, Some(11.8));
+ assert_eq!(topic.ack_rate, Some(11.2));
+ let arguments = topic.arguments.as_ref().expect("arguments");
+ assert_eq!(arguments["x-message-ttl"], serde_json::json!(60000));
+ assert_eq!(arguments["x-queue-type"], serde_json::json!("quorum"));
+ }
+
+ #[test]
+ fn topic_info_accepts_consumers_wire_field() {
+ let topic = topic_info_from_agent_value(&serde_json::json!({
+ "name": "orders",
+ "consumers": 3
+ }));
+
+ assert_eq!(topic.consumer_count, Some(3));
+ }
+
+ #[test]
+ fn topic_info_falls_back_to_x_queue_type_argument() {
+ // Older RabbitMQ versions only expose the queue type in arguments.
+ let topic = topic_info_from_agent_value(&serde_json::json!({
+ "name": "stream-q",
+ "arguments": { "x-queue-type": "stream" }
+ }));
+ assert_eq!(topic.queue_type.as_deref(), Some("stream"));
+
+ // No type anywhere: absent, never guessed.
+ let plain = topic_info_from_agent_value(&serde_json::json!({"name": "plain"}));
+ assert_eq!(plain.queue_type, None);
+ assert_eq!(plain.arguments, None);
+ assert_eq!(plain.publish_rate, None);
+ }
+
+ #[test]
+ fn topic_stats_parses_rates_and_counters_from_agent_payload() {
+ let stats = topic_stats_from_agent_value(serde_json::json!({
+ "name": "orders",
+ "totalMessages": 123,
+ "consumerCount": 4,
+ "publishRate": 12.5,
+ "deliverRate": 11.8,
+ "ackRate": 11.2,
+ "publishTotal": 1000,
+ "deliverGetTotal": 900,
+ "ackTotal": 880
+ }));
+
+ assert_eq!(stats.msg_rate_in, 12.5);
+ assert_eq!(stats.msg_rate_out, 11.8);
+ assert_eq!(stats.backlog_size, 123);
+ assert_eq!(stats.subscription_count, 4);
+ assert_eq!(stats.msg_in_counter, 1000);
+ assert_eq!(stats.msg_out_counter, 900);
+ assert!(!stats.rates_unavailable, "rates sampled by the management API");
+ }
+
+ #[test]
+ fn topic_stats_marks_rates_unavailable_when_message_stats_is_missing() {
+ // No message_stats sample (fallback path, idle queue, rates_mode=none):
+ // the zero placeholders must not be presented as real rates.
+ let stats = topic_stats_from_agent_value(serde_json::json!({
+ "name": "idle",
+ "totalMessages": 5,
+ "consumerCount": 0
+ }));
+
+ assert_eq!(stats.msg_rate_in, 0.0);
+ assert!(stats.rates_unavailable, "rates must be flagged unavailable");
+
+ // And a real sampled zero is NOT flagged: it is a genuine rate of 0.
+ let zero = topic_stats_from_agent_value(serde_json::json!({
+ "name": "quiet",
+ "totalMessages": 0,
+ "consumerCount": 0,
+ "publishRate": 0.0,
+ "deliverRate": 0.0,
+ "ackRate": 0.0
+ }));
+ assert_eq!(zero.msg_rate_in, 0.0);
+ assert!(!zero.rates_unavailable, "a real zero rate is not unavailable");
+ }
+
+ #[test]
+ fn topic_stats_serialization_omits_rates_unavailable_when_false() {
+ let stats = topic_stats_from_agent_value(serde_json::json!({
+ "name": "q", "totalMessages": 1, "consumerCount": 0, "publishRate": 3.5
+ }));
+ let json = serde_json::to_value(&stats).expect("serialize stats");
+ assert!(json.get("ratesUnavailable").is_none());
+
+ let unavailable = topic_stats_from_agent_value(serde_json::json!({
+ "name": "q", "totalMessages": 1, "consumerCount": 0
+ }));
+ let json = serde_json::to_value(&unavailable).expect("serialize stats");
+ assert_eq!(json.get("ratesUnavailable"), Some(&serde_json::json!(true)));
+ }
+
#[test]
fn peeked_message_maps_agent_fields() {
let msg = serde_json::json!({
diff --git a/crates/dbx-core/src/mq/adapters/rocketmq.rs b/crates/dbx-core/src/mq/adapters/rocketmq.rs
index 5895afe0fc..f9ede44997 100644
--- a/crates/dbx-core/src/mq/adapters/rocketmq.rs
+++ b/crates/dbx-core/src/mq/adapters/rocketmq.rs
@@ -285,6 +285,7 @@ impl MessageQueueAdmin for RocketMqAdmin {
msg_out_counter: 0,
subscription_count: 0,
producer_count: 0,
+ rates_unavailable: false,
raw: result,
})
}
@@ -766,6 +767,7 @@ fn topic_info_from_agent_value(t: &serde_json::Value) -> TopicInfo {
message_count: None,
messages_ready: None,
messages_unacked: None,
+ ..Default::default()
}
}
diff --git a/crates/dbx-core/src/mq/types.rs b/crates/dbx-core/src/mq/types.rs
index e8cdaa32f7..561197a3b1 100644
--- a/crates/dbx-core/src/mq/types.rs
+++ b/crates/dbx-core/src/mq/types.rs
@@ -340,6 +340,36 @@ pub struct TopicInfo {
/// RabbitMQ messages delivered but not yet acknowledged.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub messages_unacked: Option<i64>,
+ /// RabbitMQ queue: auto-delete flag.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub auto_delete: Option<bool>,
+ /// RabbitMQ queue: exclusive flag.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub exclusive: Option<bool>,
+ /// RabbitMQ queue: state (running / idle / flow / blocked ...).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub state: Option<String>,
+ /// RabbitMQ queue: type (classic / quorum / stream), from the management
+ /// API `type` field or the x-queue-type argument on older versions.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub queue_type: Option<String>,
+ /// RabbitMQ queue: x-arguments, preserving the original JSON value types
+ /// (numbers, booleans, nested objects/arrays) returned by the management API.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub arguments: Option<serde_json::Value>,
+ /// RabbitMQ queue: consumer count.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub consumer_count: Option<i64>,
+ /// RabbitMQ queue: publish rate (msg/s). Absent when the management API
+ /// sampled no message_stats data for this queue.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub publish_rate: Option<f64>,
+ /// RabbitMQ queue: deliver/get rate (msg/s).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub deliver_rate: Option<f64>,
+ /// RabbitMQ queue: ack rate (msg/s).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub ack_rate: Option<f64>,
}
#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)]
@@ -365,6 +395,12 @@ pub struct TopicStats {
pub msg_out_counter: i64,
pub subscription_count: u32,
pub producer_count: u32,
+ /// RabbitMQ: true when the management API exposed no `message_stats`
+ /// sample for the queue, so the msg_rate_* / counter fields are NOT
+ /// meaningful — consumers must render them as "no data" instead of
+ /// presenting the zero placeholder as a real rate of 0.
+ #[serde(default, skip_serializing_if = "std::ops::Not::not")]
+ pub rates_unavailable: bool,
/// Original raw stats JSON, for the detail view / advanced inspection.
#[serde(default, skip_serializing_if = "serde_json::Value::is_null")]
pub raw: serde_json::Value,
diff --git a/crates/dbx-core/src/schema.rs b/crates/dbx-core/src/schema.rs
index 7b1527689b..207a347f66 100644
--- a/crates/dbx-core/src/schema.rs
+++ b/crates/dbx-core/src/schema.rs
@@ -3729,6 +3729,7 @@ for line in sys.stdin:
message_count: None,
messages_ready: None,
messages_unacked: None,
+ ..Default::default()
}]);
assert_eq!(tables.len(), 1);