{"record":{"id":"b3d0f9c183f08d3e","repo":"apache/rocketmq","slug":"the-consumer-group-consumergroup-has-been-creat-b3d0f9","errorCode":null,"errorMessage":"The consumer group[{consumerGroup}] has been created before, specify another name please.","messagePattern":"The consumer group\\[(.+?)\\] has been created before, specify another name please\\.","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java","lineNumber":992,"sourceCode":"                    this.consumeMessagePopService = new ConsumeMessagePopOrderlyService(this, (MessageListenerOrderly) this.getMessageListenerInner());\n                } else if (this.getMessageListenerInner() instanceof MessageListenerConcurrently) {\n                    this.consumeOrderly = false;\n                    this.consumeMessageService =\n                        new ConsumeMessageConcurrentlyService(this, (MessageListenerConcurrently) this.getMessageListenerInner());\n                    //POPTODO reuse Executor ?\n                    this.consumeMessagePopService =\n                        new ConsumeMessagePopConcurrentlyService(this, (MessageListenerConcurrently) this.getMessageListenerInner());\n                }\n\n                this.consumeMessageService.start();\n                // POPTODO\n                this.consumeMessagePopService.start();\n\n                boolean registerOK = mQClientFactory.registerConsumer(this.defaultMQPushConsumer.getConsumerGroup(), this);\n                if (!registerOK) {\n                    this.serviceState = ServiceState.CREATE_JUST;\n                    this.consumeMessageService.shutdown(defaultMQPushConsumer.getAwaitTerminationMillisWhenShutdown());\n                    throw new MQClientException(\"The consumer group[\" + this.defaultMQPushConsumer.getConsumerGroup()\n                        + \"] has been created before, specify another name please.\" + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),\n                        null);\n                }\n\n                mQClientFactory.start();\n                log.info(\"the consumer [{}] start OK.\", this.defaultMQPushConsumer.getConsumerGroup());\n                this.serviceState = ServiceState.RUNNING;\n                break;\n            case RUNNING:\n            case START_FAILED:\n            case SHUTDOWN_ALREADY:\n                throw new MQClientException(\"The PushConsumer service state not OK, maybe started once, \"\n                    + this.serviceState\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),\n                    null);\n            default:\n                break;\n        }","sourceCodeStart":974,"sourceCodeEnd":1010,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java#L974-L1010","documentation":"During start(), after services are booted the consumer tries mQClientFactory.registerConsumer(consumerGroup, this). If a consumer with the same group is already registered in this client instance (the shared MQClientInstance), registerOK is false; the code rolls back its own state to CREATE_JUST, shuts down the consume service, and throws with the GROUP_NAME_DUPLICATE FAQ hint.","triggerScenarios":"Starting two DefaultMQPushConsumer objects with the same consumerGroup within one JVM/client instance (same clientId: ip@instanceName@unitName); restarting a consumer whose shutdown did not fully unregister it; same instanceName reused for multiple consumers.","commonSituations":"Hot-reload or Spring context refresh creating a second consumer with the same group and same instanceName; embedding two consumer beans reading the same group; a previous shutdown() that did not complete unregisterConsumer so the factory still holds the group.","solutions":["Give each consumer in the same JVM a unique instanceName (consumer.setInstanceName(...)) so they get separate MQClientInstance objects","Ensure the old consumer is fully shutdown() before starting a replacement; in Spring use destroy-method and avoid duplicate component scanning","If both consumers legitimately share a group, they must also share the same MQClientInstance — instead use ONE consumer instance, not two","Check for duplicate bean definitions / config files instantiating the consumer twice"],"exampleFix":"// before\nDefaultMQPushConsumer c1 = new DefaultMQPushConsumer(\"order-group\"); c1.start();\nDefaultMQPushConsumer c2 = new DefaultMQPushConsumer(\"order-group\"); c2.start(); // same clientId -> exception\n\n// after\nDefaultMQPushConsumer c2 = new DefaultMQPushConsumer(\"order-group\");\nc2.setInstanceName(\"order-group-consumer-2\"); // distinct MQClientInstance\nc2.start();","handlingStrategy":"validation","validationCode":"// ensure a group is registered at most once per client instance before starting\nMQClientInstance factory = ...; // internal; in practice: track groups in your app\nif (registeredGroups.add(consumerGroup)) { consumer.start(); }\nelse throw new IllegalStateException(\"group already started in this JVM: \" + consumerGroup);","typeGuard":null,"tryCatchPattern":"try {\n    consumer.start();\n} catch (MQClientException e) {\n    if (e.getMessage().contains(\"has been created before\")) {\n        // pick unique instanceName or unique group, rebuild consumer, retry once\n    } else throw e;\n}","preventionTips":["Give every consumer in a JVM a unique instanceName and group pair","In Spring, expose exactly one bean per consumer; watch for context refresh duplicates","Call shutdown() reliably (destroy-method) before replacing consumers at runtime"],"tags":["rocketmq","consumer-group","duplicate","lifecycle"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}