Subprocess with message correlation and parallel gateway

Hi,

I have created subprocess and subprocess has parallel gateway to process the post process activities. Below is my workflow design.

Initially I have not created message correlation for subprocess. With no correlation message creation, parallel gateway was not executing and unable to process any post process delegate. Then I realised the correlation message and created it. However I am still getting nullpointer for few variables (Ex: Activity) after creating the message correlation. Please suggest me what I missed in my delegate class.

Java code:

@Component(value = "postProcessExecutionDelegate")
public class PostProcessExecutionDelegate implements JavaDelegate {

    @Override
    public void execute(DelegateExecution execution) {
        log.info("Executing sub post processing for Envelope Review: {}", execution.getBusinessKey());
        String messageName = extractThrowEventMessageName(execution);
        execution.getProcessEngineServices().getRuntimeService()
                .createMessageCorrelation(messageName)
                .processInstanceId(execution.getProcessInstanceId())
                .processInstanceBusinessKey(execution.getProcessBusinessKey())
                .correlateExclusively();
    }

    private String extractThrowEventMessageName(DelegateExecution execution) {
        ThrowEvent messageEvent = (ThrowEvent) execution.getBpmnModelElementInstance();
        MessageEventDefinition messageEventDefinition = (MessageEventDefinition) messageEvent.getEventDefinitions()
                .iterator()
                .next();
        return messageEventDefinition.getMessage().getName();
    }
}

Where are you sending the message from exactly?

Hi @camundabeginner,

I see that you are trying to communicate back to the main process from within the event sub-process.

If this is your intended goal, then you can simply have your Post Processing logic modeled in a separate pool.

Messages should be used as a way of communication between processes reside in separate pools (not in a single pool).

@hassang is exactly right.
Also the event sub process is triggered by an interrupting message event - which means the token in the main process will be canceled when the message comes in.

I would suggest using signal events or conditional events rather than message events.

1 Like

Thank you @hassang and @Niall .
I’m sending the message from Trigger post processing (Message Intermediate throwing Event with Global message ref). I will look at the suggested options.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.