{"record":{"id":"154fc29678b0ddbd","repo":"flowable/flowable-engine","slug":"could-not-start-process-instance-with-business-key","errorCode":null,"errorMessage":"Could not start process instance with business key ${key}","messagePattern":"Could not start process instance with business key (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-camel/src/main/java/org/flowable/camel/FlowableProducer.java","lineNumber":164,"sourceCode":"        if (execution == null) {\n            throw new FlowableException(\"Could not find activity \" + activity + \" for processId \" + processInstanceId +\n                    \" in defined timeout of \" + timeout + \" ms.\");\n        }\n\n        runtimeService.setVariables(execution.getId(), ExchangeUtils.prepareVariables(exchange, getFlowableEndpoint()));\n        runtimeService.trigger(execution.getId());\n    }\n\n    protected String findProcessInstanceId(Exchange exchange) {\n        String processInstanceId = exchange.getProperty(PROCESS_ID_PROPERTY, String.class);\n        if (processInstanceId != null) {\n            return processInstanceId;\n        }\n        String key = exchange.getProperty(PROCESS_KEY_PROPERTY, String.class);\n        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceBusinessKey(key).singleResult();\n\n        if (processInstance == null) {\n            throw new FlowableException(\"Could not start process instance with business key \" + key);\n        }\n        return processInstance.getId();\n    }\n\n    protected ProcessInstance startProcess(Exchange exchange) {\n        FlowableEndpoint endpoint = getFlowableEndpoint();\n        String key = exchange.getProperty(PROCESS_KEY_PROPERTY, String.class);\n        try {\n            if (endpoint.isSetProcessInitiator()) {\n                setProcessInitiator(ExchangeUtils.prepareInitiator(exchange, endpoint));\n            }\n\n            if (key == null) {\n                return runtimeService.startProcessInstanceByKey(processKey, ExchangeUtils.prepareVariables(exchange, endpoint));\n            } else {\n                return runtimeService.startProcessInstanceByKey(processKey, key, ExchangeUtils.prepareVariables(exchange, endpoint));\n            }\n","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-camel/src/main/java/org/flowable/camel/FlowableProducer.java#L146-L182","documentation":"FlowableProducer.findProcessInstanceId resolves the process instance id for an exchange by querying Flowable with the business key taken from the PROCESS_KEY_PROPERTY exchange property. If no process instance exists with that business key, Flowable throws this FlowableException because the exchange assumed a process was already started under that key.","triggerScenarios":"Using the exchange-correlation mode (no explicit process instance id) where process() looks up the instance via processInstanceBusinessKey(key), but the process instance with that business key was never started, already completed, or the property value is wrong.","commonSituations":"Sending a follow-up exchange to a flowable endpoint before the initial one started the process; process already finished (history only, not runtime query); business key mutated or generated differently between calls; camelContext mismatch so the key property is absent/null.","solutions":["Ensure the process instance was actually started (with that business key) before sending subsequent exchanges correlated by the key.","Verify the exchange property FlowableConstants.PROCESS_KEY_PROPERTY is set to the same value used at startProcess.","Check the process has not already completed; query history (historicProcessInstanceQuery) to confirm its lifecycle.","Alternatively pass the processInstanceId directly via the PROCESS_INSTANCE_ID_PROPERTY to skip business-key lookup."],"exampleFix":"// before\nexchange.setProperty(ExchangeUtils.PROCESS_KEY_PROPERTY, \"order-42\"); // never started\n// after\nexchange.setProperty(ExchangeUtils.PROCESS_KEY_PROPERTY, \"order-42\");\nruntimeService.startProcessInstanceByKey(\"myProcess\", \"order-42\"); // then correlate","handlingStrategy":"validation","validationCode":"String key = exchange.getProperty(ExchangeUtils.PROCESS_KEY_PROPERTY, String.class);\nif (key == null || runtimeService.createProcessInstanceQuery()\n        .processInstanceBusinessKey(key).singleResult() == null) {\n    throw new IllegalStateException(\"No running process instance for business key \" + key);\n}","typeGuard":null,"tryCatchPattern":"try {\n    producer.process(exchange);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"Could not start process instance with business key\")) {\n        // start the process first, or fall back to startProcess\n    }\n    throw e;\n}","preventionTips":["Always start the process (with the business key) before sending correlated follow-up exchanges.","Pass the processInstanceId property directly when known to avoid key lookup.","Treat completed instances: query history when runtime lookup fails."],"tags":["camel","flowable","business-key","process-instance"],"backgroundTag":"record-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}