Camunda 8 Message Correlation - as external system I want to know if correlation has been successful

Hi folks,

with Camunda 8 I love that we now have message buffering and external systems can emit messages before a process arrives at the catch event.

But there are still cases, where - as external system - I want to know if message correlation has been succuessful right when sending the message. Which is that I want to get a result which informs me if a corresponding process instance has been found or not.

Because in that case I’m not interested in buffering I use Spring Zeebe Client with TTL=0 as follows:

var result = client.newPublishMessageCommand()
				.messageName(MESSAGE_XXX_RECEIVED)
				.correlationKey(technicalCorrelationId)
				.variables(Collections.singletonMap(XXX_DATA, xxxData))
				.timeToLive(Duration.ZERO)
				.send().join();

Sadly the result - of type PublishMessageResponse - only has a message key as result. And I always get such a message key. Totally independent of the question whether an existing process instance with the right correlation key exists or not.
With a TTL of Zero I would have expected to get either an appropriate exception or some flag in the result in order to know if my action has been successful or not.

Maybe I’m just missing a small detail here - and I would be happy to know how to achieve this. Any ideas?

Thanks in advance
Gunnar

Hey Gunnar,
I love your question! - You are completely correct in your “observation”. Apparently there is currently no possibility to get the information if the actual correlation was successful.

Good thing though: We are well aware of this and are looking for possibilities to fix this :slight_smile:

Best,
Thomas

2 Likes

Hello,
I came up with the exactly the same question while evaluating Camunda for an upcoming customer project.

I’d like to opt for Camunda Platform 8, but this limitation may be a blocker, as the project code need to perform some intelligent process integration, such as verifying if any currently running processes instance are able (in their current state) to pick up and process a concurrent external event about the target item, only creating a dedicated new process instance to handle it otherwise.

In an embedded Camunda 7 solution I could, as far as I understood, attempt to correlate a message and (synchronously) examine the correlation results to make the decision, using the MessageCorrelationBuilder.correlateWithResults APIs.

Do you guys have any plan about improving the zeebe java client to support this use case?

In the meantime, do you have any suggested pattern to achieve a similar with Camunda Platform 8? For example, could starting a specific dedicated process (and delegate to it the decision) help in some way? Would this process be in a better position to decide what to to do, using standard BPMN constructs? (I’m not able to figure out the details of such a workaround at the moment.)

Thank you very much in advance
Cosma

Hey @cosmacol!
Thanks for your feedback - appreciate it. :slight_smile:
I will route it to our product management to get some information if and when this functionality is planned to be added. Maybe @aleksander-dytko or @felix-mueller can shed some light on this right away?

So far I am not aware of any workaround either…
Best,
Thomas

1 Like

This thread is almost one year old. Just wondering if there is already a solution to this issue @Hafflgav ? I just asked chatGPT and it thought that the correlation failed when getMessageKey() returns 0, but I could not confirm this in the ZeeBe client documentation.

@bremme:
I’d rather ask the Camunda experts than chatGPT :wink:
See camunda-8-examples/synchronous-response-springboot at main · camunda-community-hub/camunda-8-examples · GitHub for a pattern on how to deal with such “synchronous” response requirements. At least this is the best workaround I currently know. And useful in quite a lot of other use cases as well.

1 Like

Thanks for your reply! This does not really seem suitable for our use case I think. Let me explain a little bit more what I’m trying to achieve.

Our application consumes Kafka messages and depending on the type of message we received we either start a process using a message start event or correlate a message to an already running instance using the ZeeBe client. In any case, but especially in the case of correlating to a running instance we would like to know if the correlation was successful. In other words, there was a running instance waiting in a specific receive task with the exact correlation key.

The response does not have to be synchronous. But the main problem is that it seems that the (eventually) returned PublishMessageResponse does not contain any information on if the correlation (or starting of the process) was successful. Nor do we get an exception when the correlation fails.

It seems reasonable to be able to know when you try to start a process or correlate a message that there is an easy way to find out? But perhaps we just have to change our approach or way of thinking, but this is what we are struggling with.

Hi @bremme,

I totally understand what you like to have. This is why I opended this topic and I really would enjoy having a solution directly visible in the PublishMessageResponse. I don’t know if meanwhile this has been solved in a way I missed to see - if so please let us know.

You can adapt the sample for synchronous responses for message receive events as follows:

grafik grafik

If you model the acknowledgement with a dynamic type as shown you’re able to achieve exactly what you want:

  • correlate a message with your process instance
  • afterwards check if the message has been received - and do that “synchronously” with a timeout (see code of the linked example)

You have to think in a different way, of course. As long as there is no other solution this is the way to go.

2 Likes