{"record":{"id":"09922794c847be29","repo":"flowable/flowable-engine","slug":"cannot-deploy-process-definition-s-there-alrea","errorCode":null,"errorMessage":"Cannot deploy process definition '%s': there already is a message event subscription for the message with name '%s'.","messagePattern":"Cannot deploy process definition '(.+?)': there already is a message event subscription for the message with name '(.+?)'\\.","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/deployer/BpmnDeployer.java","lineNumber":434,"sourceCode":"                    List<MessageEventSubscriptionEntity> cachedSubscriptions = commandContext\n                            .getDbSqlSession()\n                            .findInCache(MessageEventSubscriptionEntity.class);\n                    for (MessageEventSubscriptionEntity cachedSubscription : cachedSubscriptions) {\n                        if (eventDefinition.getEventName().equals(cachedSubscription.getEventName())\n                                && !subscriptionsForSameMessageName.contains(cachedSubscription)) {\n                            subscriptionsForSameMessageName.add(cachedSubscription);\n                        }\n                    }\n                    // remove subscriptions deleted in the same command\n                    subscriptionsForSameMessageName = commandContext\n                            .getDbSqlSession()\n                            .pruneDeletedEntities(subscriptionsForSameMessageName);\n\n                    for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsForSameMessageName) {\n                        // throw exception only if there's already a subscription as start event\n                        if (eventSubscriptionEntity.getProcessInstanceId() == null || eventSubscriptionEntity.getProcessInstanceId().isEmpty()) {\n                            // the event subscription has no instance-id, so it's a message start event\n                            throw new ActivitiException(\"Cannot deploy process definition '\" + processDefinition.getResourceName()\n                                    + \"': there already is a message event subscription for the message with name '\" + eventDefinition.getEventName() + \"'.\");\n                        }\n                    }\n\n                    MessageEventSubscriptionEntity newSubscription = new MessageEventSubscriptionEntity();\n                    newSubscription.setEventName(eventDefinition.getEventName());\n                    newSubscription.setActivityId(eventDefinition.getActivityId());\n                    newSubscription.setConfiguration(processDefinition.getId());\n                    newSubscription.setProcessDefinitionId(processDefinition.getId());\n\n                    if (processDefinition.getTenantId() != null) {\n                        newSubscription.setTenantId(processDefinition.getTenantId());\n                    }\n\n                    newSubscription.insert();\n                }\n            }\n        }","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/deployer/BpmnDeployer.java#L416-L452","documentation":"A message name must be globally unique for message start events: the deployer checks the event subscription table (ACT_RU_EVENT_SUB) for existing start-event subscriptions (those with no processInstanceId) using the same message name. If one exists, the new deployment is rejected to avoid nondeterministic message correlation.","triggerScenarios":"deploy -> addMessageEventSubscriptions when the new process definition's message start event name matches an existing start-event subscription in the database, typically created by a previously deployed process definition.","commonSituations":"Deploying a second, differently-keyed process that uses the same message name as an already deployed process; test environments sharing one database; failing to undeploy/delete an old definition that still holds the subscription.","solutions":["Delete the old process definition deployment that holds the conflicting message start subscription","Use a unique message name for the new process definition","Clean up orphaned rows in ACT_RU_EVENT_SUB if they belong to removed definitions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"List<EventSubscription> subs = runtimeService.createEventSubscriptionQuery()\n    .eventName(messageName).eventType(\"message\").list();\nboolean conflict = subs.stream().anyMatch(s -> s.getProcessInstanceId() == null);","typeGuard":null,"tryCatchPattern":"try {\n    repositoryService.createDeployment().addClasspathResource(model).deploy();\n} catch (org.activiti.engine.ActivitiException e) {\n    if (e.getMessage().contains(\"already is a message event subscription\")) {\n        // delete the old deployment or rename the message\n    }\n}","preventionTips":["Reserve globally unique message names per process definition","Delete old deployments that hold message start subscriptions before redeploying with the same name","Don't share one test database across environments deploying conflicting models"],"tags":["bpmn","deployment","message-event","conflict"],"backgroundTag":"conflicting-event-subscription","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}