How to send message from one task to another task in camunda BPMN 2.0

Hi dears I am new to camunda and I want to send a message from one task with message name “cancelorder” to another receive message task and I have added java delegate to the sender task and I have configured the receiver in the camunda modeler with the same message name “cancelorder”
public void execute(DelegateExecution execution) throws Exception {

    execution.getProcessEngineServices()
      .getRuntimeService()
      .createMessageCorrelation("cancelorder")
      .processInstanceBusinessKey("hotel")
      .correlateAll();

  }

this works on the sender task but when it reaches the message receiver task it will not proceed to the next task. could someone point me how to do this or is there anything I can add to the message receiver task in addition to configuring it in camunda modeler

Hello @briye,

Do you want to throw and catch a message within the same process instance? Because it is not a good idea.
Could you please attach you process.

Best regards,
Yana

camunda

I want to send cancel order message from the “cancel order” task to “received message” what can I implement in the receiver task. I have used the above code in the sender but I have done nothing in the receiver except configuring in the camunda modeler with the same message name. it works there is no error but it will not proceed to the next service tax i.e "return money " (this task is not executing )
thanks for your help!

Hello,

When the message is sent in “cancel order” no body is waiting for it and that is why it won’t be received in “received message” (and won’t continue to “return money”). Why do you need this, what is the reasoning behind this?
Send message from one task to another within the same process will not work.
I believe that you can implement it in different way. If the second lane is another user, you can just reassign a task (Manual for example) to them.

Best regards,
Yana

1 Like

Hello dear
if I have not missed some concepts in the BPMN diagram I have two actors i.e the first lane “customer” and second lane “system” from this when the customer sends cancel order message(“cancel order” task) the system receives an order cancellation message (“received message” task) and it will return money using the service task to the customer.
Send message from one task to another within the same process will not work? this is not clear for me what about if I have two pool one “customer” and the other “system”?
and how to assign tasks this because in the camunda modeler there is no option for assigning except for user tasks?

thanks a lot for your help

Hi,

In the BPMN specification is not stated clear that such scenario (send message from one task to another within the same process) is not allowed.
However in your case, it does not make sense to have send and then receive task, one after another in the flow. The second task will be reached but never executed as I explained before.
You should use two pools instead of lanes as you said. This means that you will have two processes, and exchanging messages between them is perfectly fine.

Please let me know if something is still not clear and you have questions.

Best regards,
Yana

1 Like

As explained by yana, messages are for inter-process communication and event throw and cache. For within the single process flow it can be flow design using gateways, object mapping, and task assignment.

ok now I understand the problem thank you so much @yana.vasileva and @kshahpune