Problem correlating a message with a process instance in Camunda 7 when starting the process

Hi everyone,

I am trying to start a process in Camunda 7 and simultaneously send a message (with “Intermediate Throw Event”) that is related to this process through an “Intermediate Catch Event”.

What I want to do is that the “message sent” event triggers the “message came” event in another process instance. I am implementing a JavaClass in the message intermediate throw event:

import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

@Component
public class SendMessageDelegation implements JavaDelegate {
    private final RuntimeService runtimeService;

    public SendMessageDelegation(RuntimeService runtimeService) {
        this.runtimeService = runtimeService;
    }

    @Override
    public void execute(DelegateExecution delegateExecution) throws Exception {
        String messageName = "MensajePreventivoRiesgo";
        runtimeService.createMessageCorrelation(messageName)
                .correlate();
        System.out.println("Evento de mensaje 'MensajePreventivoRiesgo' disparado.");
    }
}

But I obtain this error:

This is the elements configuration

I would be immensely grateful if someone could explain to me how this type of event works in this case. The process I have has two lanes, the idea being that instances are executed in each one.

Thanks for you attention!

Hey, welcome back!

Intermediate Catch requires a process flow to reach it before it will start listening, so the way your diagram is presented, it will never start listening at “Message came”

However, it looks like you’re trying to throw and catch within a single process. This isn’t allowed. A message MUST cross a process boundary.

Simple way to move forward:

  1. Move “Message Came”, “User Task 2”, etc into a new process
  2. Change “Message Came” from Intermediate Catch Event to Message Start Event

That should take care of things…