Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receivetask in camunda is not working as expected

Tags:

spring

camunda

We have been using camunda 7.4 version in most of our projects along with camunda-bpm-spring-boot-starter 1.1.0.

We have a project where in the camunda flow we try to publish a message to a message broker which internally is consumed by another system and re-publish a new message to the same message broker. Then we trigger a receiveTask to receive that message and process further. To listen to the incoming message we use org.springframework.amqp.core.MessageListener and we define the message co-relation for receiveTask within the onMessage() method. But we get below error in doing so

org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message 'ReceiveAmsharedResponse': No process definition or execution matches the parameters

We are trying to figure where the problem is? Is it in the version of camunda we are using or the problem is with the usage of receiveTask. We tried all approaches defined in https://docs.camunda.org/manual/7.4/reference/bpmn20/tasks/receive-task/ but no luck.

For the method createMessageCorrelation we get above error. And for other methods we get a NPE as EventSubscription/Execution objects are null.

Sample Camunda flow receiveTask Usage is as below:

 <bpmn2:receiveTask id="ReceiveTask" name="Receive Task" messageRef="Message_06nl07f">
  <bpmn2:incoming>SequenceFlow_xyz</bpmn2:incoming>
  <bpmn2:outgoing>SequenceFlow_190m9nx</bpmn2:outgoing>
</bpmn2:receiveTask>
......
......
<bpmn2:message id="Message_06nl07f" name="Message" />

And sample message co-relation code:

 class XYZ implements MessageListener {
 onMessage() {
    runtimeService.createMessageCorrelation("Message")
                .processInstanceBusinessKey(resourceId)
                .setVariable(ACTIVITY_RESULT, activityResult)
                .correlate();
 }

Any help would be appreciated?

Thanks, Viswanath

like image 691
Sai Viswanath VKS Palaparthi Avatar asked Mar 13 '17 10:03

Sai Viswanath VKS Palaparthi


People also ask

Why do we use collapsed pools in Camunda?

A collapsed pool is used to represent a system which supports the process and/or carries out process tasks on its own. The pool could be expanded later to model the internal system details, maybe even with the goal to execute a technical process flow directly with a BPMN capable process engine.

What is send task in Camunda?

A send task is used to model the publication of a message to an external system; for example, to a Kafka topic or a mail server. Send tasks behave exactly like service tasks. Both task types are based on jobs and job workers.

What is pool in Camunda?

To BPMN, the pool represents a higher-ranking instance compared to its lanes. The pool assumes process control – in other words, it assigns the tasks. It behaves like the conductor of an orchestra, and so this type of process is called “orchestration.”

What is process engine in Camunda?

Camunda's Workflow Engine executes processes that are defined in Business Process Model and Notation (BPMN), the global standard for process modeling. With BPMN, you can automate your most complex business processes using an easy-to-adopt visual modeling language.


2 Answers

Assuming your process looks something like this:

O -- ( M ) -- ( M ) -- O
     send    receive

If the response message is send very fast, it possible that the onMessage and message correlation is executed before the message event subscription is persisted in the database. Basically the message arrives while the send task is stil being executed.

One way to avoid this would be to create the message subscription in parallel with sending the event:

O -- + -- ( M ) -- + -- O
     |    send     |
     `----( M ) --´
         receive
like image 71
Jörn Horstmann Avatar answered Sep 28 '22 06:09

Jörn Horstmann


Regarding to the given exception message which is :

org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message 'ReceiveAmsharedResponse': No process definition or execution matches the parameters

I assume that you correlate a message with the name ReceiveAmsharedResponse, but you defined a Message with a different name for your ReceiveTask.

Changing the definition of your Message to the following should work:

<bpmn2:message id="Message_06nl07f" name="ReceiveAmsharedResponse" />
like image 44
Zelldon Avatar answered Sep 28 '22 06:09

Zelldon