首页 > 解决方案 > Camunda - 中间消息事件不能与单个执行相关联

问题描述

我创建了一个小型应用程序(Spring Boot 和 camunda)来处理订单流程。Order-Service 通过 Rest 接收新订单并调用 BPMN Order 工作流的 Start Event。订单流程包含两个异步 JMS 调用(客户检查和仓库库存检查)。如果两项检查均返回,则订单流程应继续。

在 Spring Rest Controller 中调用 Start 事件:

     ProcessInstance processInstance =
             runtimeService.startProcessInstanceByKey("orderService", String.valueOf(order.getId()));

发送任务(例如客户检查)将 JMS 消息发送到异步队列中。该服务的答案被另一个 Spring 组件捕获,然后尝试发送中间消息:

     runtimeService.createMessageCorrelation("msgReceiveCheckCustomerCredibility")
             .processInstanceBusinessKey(response.getOrder().getBpmnBusinessKey())
             .setVariable("resultOrderCheckCustomterCredibility", response)
             .correlate();

我停用了仓库服务以查看订单流程是否等待第二次调用的到来,但我得到了这个异常:

  1115 06:33:08.564 WARN  [o.c.b.e.jobexecutor] ENGINE-14006 Exception while executing job  67d2cc24-0769-11ea-933a-d89ef3425300: 
  org.springframework.messaging.MessageHandlingException: nested exception is org.camunda.bpm.engine.MismatchingMessageCorrelationException: ENGINE-13031 Cannot correlate a message with name 'msgReceiveCheckCustomerCredibility' to a single execution. 4 executions match the correlation keys: CorrelationSet [businessKey=1, processInstanceId=null, processDefinitionId=null, correlationKeys=null, localCorrelationKeys=null, tenantId=null, isTenantIdSet=false]

这是我的过程。我看不到发布 bpmn 文件的方法 :-( 在此处输入图像描述

什么不能与消息名称和业务密钥不相关?JMS 队列为空,还有其他具有相同业务密钥的消息在等待。

谢谢!

标签: bpmncamunda

解决方案


只是为了缩小问题范围:在您尝试关联并检查哪些订阅实际上在等待之前执行 runtimeService eventSubscription 查询。也许您有重复的消息名称?也许您(意外地)运行了同一进程的另一个实例?确定订阅后,您可以直接通知执行,而无需使用关联构建器...


推荐阅读