Camunda Message Correlation: Ensure steps consecutiveness

Greetings, everyone. I am currently working with a Camunda Process which looks like this:

As of right now, for the most part, the workflow of the process is going as it should. However, sometimes, we receive the callback for message correlation from an external service too fast (for example, we receive success2 message event while we are still working on task1), before the process waits on the Gateway for any messages, thus leading to message Correlation Exceptions.

Are there any good practices that could ensure correct behavior in this scenario?
Some of the possible solutions I have saw were involving either conditional events or event subprocesses.

Thank you in advance for any cooperation.

Hi @Salvir

This is actually a pretty common problem when you’re dealing with systems that return quickly - there are a few different options - but the easiest one is to implement the principal of waiting for the response before sending the message. That can be done like this:

The important part is to make sure that the Send Message to System task is marked asynchronous before which will ensure that it waits for a response before sending the message.

2 Likes

Thank you @Niall, I think I understood the principle to use here and will see if it will work as a solution for my specific problem.

This is clear enough. It’s the typical solution for request-callback integration pattern and external tasks solve this problem even better.

But how to deal with the same problem with publish-subscriber integration. When there are a number of events in respond and process should handle them one-by-one (in current example task2 should be started only after success2 received and after task1 is finished).
But success2 event can occur while process handle task1 and engine in this situation just miss this event and stuck on the second event-based gateway.

I think it should be a typical kind of process but I can’t find kind of “best practise” solution for such problem.

Thank you in advance