Link Message End Event and Message Start Event

Hello everyone!

I just recently started to use and learn Camunda 8 and I’m having some troubles with message events.

I have a process that I’m trying to split in 2.

The first process is a POST REST Connector call. After receiving 200 response, I want to use a Message End Event.

The second process is going to be fired with a Message Start Event linked to the Message End Event of the first process, followed by a GET REST Connector call.

I put both processes bellow.

I see a lot of information about that but it’s always with Camunda 7 and there are some options such as “Message” and “Message name” that I cannot find with the desktop app in the properties panel (is it normal?).

How could I connect these two events?

Thank you very much!


Capture d'écran 2023-06-12 153844

Hi @SimDoc,

you have to write a worker for the message end event, that invokes the publish message RPC to start the process with the message start event.

The End event needs the task type of the worker. The worker code needs the message name of the start event.

Hope this helps, Ingo

Hello @Ingo_Richtsmeier

Thank you for your reply. So it is not possible to do it within the modeler?

My original goal is to see how to implement async patterns to this diagram.

Could someone help me to understand how to apply an asynchronous way to run this workflow?

Thank you ! :slight_smile:

Hi @SimDoc,

sending a message via the Zeebe API requires code to run. I have seen several requests to do it either by a connector or directly in the Zeebe engine.

But this is not implemented yet.

The basic pattern for async processing is to model the send and receive tasks or events one after the other:
grafik

Hope this helps, Ingo

Hello @Ingo_Richtsmeier

Thank you for your reply!

So the way I was trying to do is not correct with one bpmn with process1 sending a message end event and another bpmn with process2 picking it up with a message start event?

@SimDoc
I’m currently implementing this feature. FYI: [Epic] I can publish a message from a workflow instance · Issue #1021 · camunda/zeebe · GitHub

Hi @SimDoc,

It is correct, but usually you split the process models into two diagrams. And then you get a process chain, which is a common pattern.

As an edge case, you can wrap both processes into pools, make both executable and give them separate process Ids. But if you open either the first or the second process instance in Operate, you will always see both process models. It’s easier to split them up.

Hope this helps, Ingo

@Ingo_Richtsmeier

but usually you split the process models into two diagrams. And then you get a process chain, which is a common pattern.

It is split in two diagrams.

Diagram 1 = POST connector with message end event
Diagram 2 = GET connector with message start event

When you say “process chain”, you mean the link between the two message event?

Thank you for your reply and the time you take for me. Maybe my questions are not really clear but I’m really just starting with all of this. :slight_smile:

Hi @SimDoc,

yes. Sending a message at the end of a process instance starts a new process instance catching the message.

@Ingo_Richtsmeier Ok, thank you.

So the flow would be as such:

Diagram 1 : Post request with message end event.

Diagram 2 : Get request with a message start event and a message end event.
bpmn2

Diagram 3 : Result of get response. Either finish the flow or message end event that will go back to Diagram 2.

What would be the consequences splitting the original diagram in 3 separate ones, what is the advantage of it? I don’t think I understand fully understand that. How does it make it async.

Hi @SimDoc,

The consequences are that you have created a loose coupling between your processes. As an advantage, you may reuse a process in another chain.

You send a message and don’t expect the full reply to be available synchronously. You check for the result later.

But this can all be done in a single process as well, as my process above shows. The Message receive tasks waits as well as the timer event. The difference is that don’t have to give the time beforehand.

Hope this helps, Ingo

Hello @Ingo_Richtsmeier , thank you again! Your explanation does help.

Regarding the Message receiving task, it will wait until the message is received. But here if I understand correctly, the timer event isn’t waiting a response but it’s just a timer to wait before going back to process2? At leat that’s what I wanted to do.

Hi @SimDoc,

you can either attach an interrupting timer boundary event to the receive task and don’t wait forever, or change the receive task to a receive event and model the process like here with an event based gateway: Restarting an instance - #6 by Draakzward

Hope this helps, Ingo

@Ingo_Richtsmeier

Looking at Send task/Receive task I don’t understand the implementation.

messageevent

After the gateway checking the post request response, there is the get request to retrieve a status value. Is this rest connector needed? Can the send task do the job of the get request?

Hi @SimDoc,

Yes. A Send task is a Service task. The only difference is the icon.

Hope this helps, Ingo

@Ingo_Richtsmeier Yeah ok. But do I still need to implement the Rest connector managing the get request in the bpmn?