{"record":{"id":"5825b0ae4742afb0","repo":"flowable/flowable-engine","slug":"consumer-already-defined-for-endpointuri","errorCode":null,"errorMessage":"Consumer already defined for ${endpointUri}!","messagePattern":"Consumer already defined for (.+?)!","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-camel/src/main/java/org/flowable/camel/FlowableEndpoint.java","lineNumber":101,"sourceCode":"\n    @Override\n    public Producer createProducer() throws Exception {\n        FlowableProducer producer = new FlowableProducer(this, getTimeout(), getTimeResolution());\n        producer.setRuntimeService(runtimeService);\n        producer.setIdentityService(identityService);\n        producer.setRepositoryService(repositoryService);\n        producer.setManagementService(managementService);\n        return producer;\n    }\n\n    @Override\n    public Consumer createConsumer(Processor processor) throws Exception {\n        return new FlowableConsumer(this, processor);\n    }\n\n    protected void addConsumer(FlowableConsumer consumer) {\n        if (flowableConsumer != null) {\n            throw new FlowableException(\"Consumer already defined for \" + getEndpointUri() + \"!\");\n        }\n        flowableConsumer = consumer;\n    }\n\n    protected void removeConsumer() {\n        flowableConsumer = null;\n    }\n\n    @Override\n    public boolean isSingleton() {\n        return true;\n    }\n\n    public void setIdentityService(IdentityService identityService) {\n        this.identityService = identityService;\n    }\n\n    public void setRuntimeService(RuntimeService runtimeService) {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-camel/src/main/java/org/flowable/camel/FlowableEndpoint.java#L83-L119","documentation":"FlowableEndpoint.addConsumer registers the single FlowableConsumer allowed per endpoint. Flowable throws this FlowableException when a second consumer tries to attach while one is already registered, because a flowable endpoint may only feed one route/processor.","triggerScenarios":"Starting two Camel routes with the same from(\"flowable:xxx\") URI; re-deploying/starting a route without the old one being stopped (removeConsumer not called); duplicating the endpoint definition across route builder instances.","commonSituations":"Route auto-restart or hot redeploy adding a second consumer; copy-pasted route definitions with identical flowable URIs; multiple CamelContexts sharing the same endpoint URI string in the same context.","solutions":["Remove the duplicate route consuming the same flowable URI; only one route per URI is allowed.","Ensure the previous consumer is stopped (which calls removeConsumer) before starting a new one.","Use distinct flowable endpoint URIs (different processDefinitionKey) for different routes.","If a stale consumer remains, restart the CamelContext to clear endpoint state."],"exampleFix":"// before\nfrom(\"flowable:myProcess\").to(\"direct:a\");\nfrom(\"flowable:myProcess\").to(\"direct:b\"); // second consumer\n// after\nfrom(\"flowable:myProcess\").to(\"direct:a\");\nfrom(\"flowable:otherProcess\").to(\"direct:b\");","handlingStrategy":"validation","validationCode":"long consumers = camelContext.getRoutes().stream()\n    .filter(r -> \"flowable:myProcess\".equals(r.getEndpoint().getEndpointUri()))\n    .count();\nif (consumers > 0) {\n    throw new IllegalStateException(\"Route for flowable:myProcess already exists\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    camelContext.addRoutes(myRouteBuilder);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"Consumer already defined\")) {\n        // skip duplicate registration or stop existing route first\n    }\n}","preventionTips":["Register each flowable consuming route exactly once; guard route builders against re-registration.","Stop routes properly on shutdown/redeploy so removeConsumer runs.","Use unique flowable URIs per route."],"tags":["camel","flowable","duplicate-consumer","endpoint"],"backgroundTag":"conflicting-config-options","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}