Cannot correlate message from a sub process to another sub process

Hi there,

I don’t have too much experience with Camunda and don’t know how to fix these 2 issues.

I have the following model with 2 possible path:

  1. green path or happy case that works as expected
  2. red path that doesn’t work as I need it (in orange the 2 issues)

FIRST PROBLEM

When an exception is thrown inside the Throw Error service task, the token goes to the Error handling sub process correctly but the Send Audit Msg KO message end event is unable to create a correlate message. In order works, I don’t know how to call the Audit sub process from this sub process.

This is the error I’m getting when I execute this path (at the end I have shared the gitrepo where you can execute this path):

org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message ‘audit_msg’: No process definition or execution matches the parameters

And these are the logs:

11:18:22.867 INFO: org.camunda.bpm.scenario [main] - * Starting scenario at 2023-01-12 11:18:22
11:18:22.923 INFO: org.camunda.bpm.scenario [main] - | Completed startEvent (start_event @ CamundaExample # d35fc133-926a-11ed-b388-9cfce81b2336)
11:18:22.976 INFO: example.bootstrap.CamundaConfiguration [main] - >>> executing callADelegate
11:18:22.990 INFO: org.camunda.bpm.scenario [main] - | Completed serviceTask ‘Call A’ (call_a @ CamundaExample # d35fc133-926a-11ed-b388-9cfce81b2336)
11:18:23.000 INFO: example.bootstrap.CamundaConfiguration [main] - >>> executing callBDelegate
11:18:23.012 INFO: org.camunda.bpm.scenario [main] - | Completed serviceTask ‘Call B’ (call_b @ CamundaExample # d35fc133-926a-11ed-b388-9cfce81b2336)
11:18:23.012 INFO: org.camunda.bpm.scenario [main] - | Completed exclusiveGateway ‘Throw an error?’ (Gateway_105xwbc @ CamundaExample # d35fc133-926a-11ed-b388-9cfce81b2336)
11:18:23.036 INFO: org.camunda.bpm.scenario [main] - | Canceled serviceTask ‘Throw Error’ (throw_error @ CamundaExample # d35fc133-926a-11ed-b388-9cfce81b2336)
11:18:23.036 INFO: org.camunda.bpm.scenario [main] - | Completed errorStartEvent ‘Generic error captured’ (Event_1n4vg6l @ CamundaExample # d35fc133-926a-11ed-b388-9cfce81b2336)
11:18:23.047 INFO: example.bootstrap.CamundaConfiguration [main] - >>> executing handleErrorDelegate
11:18:23.058 INFO: org.camunda.bpm.scenario [main] - | Completed serviceTask ‘Handle Error’ (handle_error @ CamundaExample # d35fc133-926a-11ed-b388-9cfce81b2336)
11:18:23.075 INFO: example.bootstrap.CamundaConfiguration [main] - >>> executing compensateBDelegate
11:18:23.083 INFO: org.camunda.bpm.scenario [main] - | Completed intermediateCompen (Event_061iuco @ CamundaExample # d35fc133-926a-11ed-b388-9cfce81b2336)
11:18:23.083 INFO: org.camunda.bpm.scenario [main] - | Completed serviceTask ‘Compensate B’ (compensate_b @ CamundaExample # d35fc133-926a-11ed-b388-9cfce81b2336)
11:18:23.097 INFO: example.bootstrap.CamundaConfiguration [main] - >>> executing sendAuditMsgKoDelegate
11:18:23.113 ERROR: org.camunda.bpm.engine.context [main] - ENGINE-16004 Exception while closing command context: Cannot correlate message ‘audit_msg’: No process definition or execution matches the parameters
org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message ‘audit_msg’: No process definition or execution matches the parameters
at org.camunda.bpm.engine.impl.cmd.CorrelateMessageCmd.execute(CorrelateMessageCmd.java:88) ~[camunda-engine-7.15.0.jar:7.15.0]
at org.camunda.bpm.engine.impl.cmd.CorrelateMessageCmd.execute(CorrelateMessageCmd.java:42) ~[camunda-engine-7.15.0.jar:7.15.0]
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28) ~[camunda-engine-7.15.0.jar:7.15.0]
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:110) ~[camunda-engine-7.15.0.jar:7.15.0]
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:72) [camunda-engine-spring-7.15.0.jar:7.15.0]



at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163) [spring-test-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.junit.runner.JUnitCore.run(JUnitCore.java:137) [junit-4.12.jar:4.12]
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) [junit-rt.jar:na]
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) [junit-rt.jar:na]
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) [idea_rt.jar:na]
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) [junit-rt.jar:na]
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) [junit-rt.jar:na]
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54) [junit-rt.jar:na]
11:18:23.127 INFO: org.camunda.bpm.scenario [main] - * Finishing scenario at 2023-01-12 11:18:22

SECOND PROBLEM

As part of the Error handling sub process I want to execute the required compensations.
e.g. if there is an error inside Throw Error service task I would like to compensate Call B and Call A
e.g. if there is an error inside Call B service task I would like to compensate only Call A

Right now I have compensate intermediate throw event that waits for Call B’s compensation, but never call Call A’s compensation

camunda-compensation

Do I have to add another compensate intermediate throw event or can I handle both compensations with a single component?

Regards,
Abel

BPMN model:
CamundaExample.bpmn (15.2 KB)

I’ve created a Github repo with 2 test cases: CamundaFlowTest

Hi @abelaneiros,

The 1’st Problem:

The two event sub-processes are listening as long as the main process is running so once the main process is ended, neither the error handling sub-process nor the audit sub-process gets triggered.

In your case, the main process gets ended while the error handling sub-process is running so the audit sub-process doesn’t listen to events anymore.

The 2nd Problem:

Try setting the Activity reference property to None

Additionally, the optional argument activityRef can be used to trigger compensation of a specific scope / activity:

1 Like

Thank a million @hassang!!!

In order to solve the 1st problem, I’ve added the core logic into an expanded sub process, this way if there is an exception I could handle it through my Error handler sub-process and after that I could continue with the Audit step:

The 2nd problem was just as you suggested.

I’ve pushed all these changes into a new branch called solution in the same repo

2 Likes