Message Intermediate Throw Event design

Hi @IdemenB,

there is no endpoint available to get the message name of a message throw event.

You either can add it by yourself using the logic I posted here: Message Intermediate Throw Event design or get the complete bpmn model xml in the piece of code where you need the message name and extract the name from the xml there.

Hope this helps, Ingo

Thank you very much @Ingo_Richtsmeier. Unfortunately, because I am using external task pattern for everyting, your implementation I can’t use. Currently, my implementation has been defining a variable for message name on start of the event and retrieving that variable.

This use case which had been questioned by people is extremely helpful for me because my design is to have a single worker class in Python that cares of all intermediate throw message events in all processes. So, I need a way to dynamically feed the class with the message name to throw from it.

Hi @IdemenB,

I would suggest to get rid of the message name and use a input parameter in the modeler for this: https://docs.camunda.org/manual/7.13/user-guide/process-engine/variables/#input-output-variable-mapping

It will create a local variable that is available in the external task directly.

Hope this helps, Ingo

1 Like

Thanks @Niall for your useful comment!
I’m actually in this situation where I’m trying to make one generic method which sends different messages. Therefore, I made use of this useful property!

I enhanced the solution that was provided by @Ingo_Richtsmeier a little bit in order to be generic for my case.
Thanks to him, he guided me to implement a generic component for my intermediate throw events which I need them to be caught by IntermediateCatchEvent in the same process instance.
So, in order to catch IntermediateThrowEvent by the same process instance I only added extra property as below.

Hope is gonna help somebody who needs such a solution.

@Slf4j
@Component
public class IntermediateThrowEventAdapter implements JavaDelegate {

@Override
public void execute(final DelegateExecution execution) {

    log.info("Passing a new activity: {}", execution.getCurrentActivityName());

    final ThrowEvent messageEvent = (ThrowEvent) execution.getBpmnModelElementInstance();
    final MessageEventDefinition messageEventDefinition = (MessageEventDefinition) messageEvent.getEventDefinitions()
        .iterator()
        .next();

    final String receivingMessageName = messageEventDefinition.getMessage().getName();

    log.info("IntermediateThrowEvent's message name: {}", receivingMessageName);

    execution.getProcessEngineServices()
        .getRuntimeService()
        .createMessageCorrelation(receivingMessageName)
        .processInstanceBusinessKey(execution.getProcessBusinessKey())
        .correlate();
}

If you want to communicate within process instance, you’d better use link events, error events or escalation events (check what fits best in you rmodel). You don’t need to cope with correlations then.