{"record":{"id":"e32a7d0baa678363","repo":"t8y2/dbx","slug":"rocketmq-topic-retention-is-broker-level-and-canno","errorCode":null,"errorMessage":"RocketMQ topic retention is broker-level and cannot be changed per topic","messagePattern":"RocketMQ topic retention is broker-level and cannot be changed per topic","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/topics.go","lineNumber":383,"sourceCode":"\t}\n\ttopicConfig, err := readTopicConfig(ctx, address, name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif entries, ok := params[\"configs\"].([]any); ok {\n\t\tfor _, raw := range entries {\n\t\t\tentry, _ := raw.(map[string]any)\n\t\t\tvalue := stringValue(entry, \"value\")\n\t\t\tswitch stringValue(entry, \"key\") {\n\t\t\tcase \"readQueueNums\":\n\t\t\t\ttopicConfig.ReadQueueNums = intValue(entry, topicConfig.ReadQueueNums, \"value\")\n\t\t\tcase \"writeQueueNums\":\n\t\t\t\ttopicConfig.WriteQueueNums = intValue(entry, topicConfig.WriteQueueNums, \"value\")\n\t\t\tcase \"perm\":\n\t\t\t\ttopicConfig.Perm = normalizeTopicPerm(intValue(entry, topicConfig.Perm, \"value\"))\n\t\t\tcase \"retention.ms\", \"retention.bytes\":\n\t\t\t\tif value != \"\" {\n\t\t\t\t\treturn nil, fmt.Errorf(\"RocketMQ topic retention is broker-level and cannot be changed per topic\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif err := writeTopicConfig(ctx, address, topicConfig); err != nil {\n\t\treturn nil, err\n\t}\n\treturn okResult(), nil\n}\n\nfunc (a *rocketMQAgent) skipTopicAccumulation(params map[string]any) (any, error) {\n\ttopic, err := requireString(params, \"topic\", \"name\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient, config, _ := a.requireClient()\n\tctx, cancel := context.WithTimeout(context.Background(), config.RequestTimeout)\n\tdefer cancel()","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/topics.go#L365-L401","documentation":"alterTopicConfig rejects attempts to set retention.ms or retention.bytes on an individual RocketMQ topic. Retention in RocketMQ is a broker-level setting (fileReservedTime / broker config), unlike Kafka where retention is a per-topic config, so the library deliberately fails fast instead of sending an unsupported key to the broker.","triggerScenarios":"Calling dispatch with an alter-topic-config action whose configs array contains an entry with key \"retention.ms\" or \"retention.bytes\" and a non-empty value. Only readQueueNums, writeQueueNums, and perm are mutable per topic.","commonSituations":"Porting Kafka automation scripts (topic-level retention.ttl.ms / retention.bytes) to RocketMQ; copy-pasted topic config templates including retention keys; IaC tooling that sets retention on every topic regardless of broker type.","solutions":["Remove the retention.ms/retention.bytes entries from the configs array and alter only readQueueNums, writeQueueNums, and perm","Change retention at the broker level instead: set fileReservedTime (and related disk settings) in the broker's broker.conf and restart/roll the brokers","Empty-string values for these keys are tolerated (no-op) — send the key with an empty value if the template must include it"],"exampleFix":"// before\nconfigs: [\n  {\"key\":\"retention.ms\",\"value\":\"259200000\"},\n  {\"key\":\"writeQueueNums\",\"value\":\"8\"}\n]\n// after\nconfigs: [\n  {\"key\":\"writeQueueNums\",\"value\":\"8\"}\n]\n// and set fileReservedTime=72 in broker.conf for broker-level retention","handlingStrategy":"validation","validationCode":"var unsupported = map[string]bool{\"retention.ms\": true, \"retention.bytes\": true}\nfor _, e := range configs {\n    if unsupported[e.Key] && e.Value != \"\" {\n        return fmt.Errorf(\"drop %s: retention is broker-level in RocketMQ\", e.Key)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only send readQueueNums, writeQueueNums, perm keys in alter-config calls","Filter Kafka-style retention keys out of shared topic-config templates per broker type","Manage retention via broker.conf fileReservedTime instead of per-topic calls"],"tags":["rocketmq","config","retention","unsupported-operation"],"backgroundTag":"unsupported-config-key","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}