Message Intermediate Throw Event design

Hey @ilyabr and @fml2,

I followed your interesting discussion and thought about an implementation.

This is a generic JavaDelegate implementation which combines the message property with a correlation to a receiving process instance:

  public void execute(DelegateExecution execution) throws Exception {
    LOG.info("Passing: {}", execution.getCurrentActivityName());
    
    ThrowEvent messageEvent = (ThrowEvent) execution.getBpmnModelElementInstance();
    MessageEventDefinition messageEventDefinition = (MessageEventDefinition) messageEvent
        .getEventDefinitions().iterator().next();
    String receivingMessageName = messageEventDefinition.getMessage().getName();
    LOG.info("Message: {}", receivingMessageName);
    
    execution.getProcessEngineServices()
      .getRuntimeService()
      .createMessageCorrelation(receivingMessageName)
      .correlate();
  }

I would say, it makes sense to use both for a thowing message event: The messageRef and the delegate implementation.

This the process model I used to test it: process.bpmn (3.3 KB)

Cheers, Ingo

1 Like