Question regarding Intermediate Message Catching event

Hi All,

I have a question regarding Intermediate Message Catching event. Let me explain with an example:

Workflow looks like following:

Start Message Event -> Task 1 -> Intermediate Catching Message Event -> Task2

Task 1 has to happen before Task 2 i.e. Task 2 is dependent on Task 1. However, there is a possibility that “Intermediate Catching Message Event” arrives before Task 1 has completed. We do not have any control over when these events arrive. At the moment, I am using following API to query for the execution required to send the event

val execution = runtimeService.createExecutionQuery()
.messageEventSubscriptionName(“Intermediate Catching Message Event Name”)
.variableValueEquals(“someid”, “id”)
.singleResult()

runtimeService.messageEventReceived(“Intermediate Catching Message Event Name”, execution.id)

This works fine, if Task1 has completed before the intermediate catching message event arrives. However, I get execution cannot be null error if Task 1 has not completed. I can understand the reason why this error is thrown.

My Question is: How do we model these scenarios with Flowable? Is there a way to effectively “park” the message so that it can be “replayed” at some point in future?

I can see a couple of options:

  • If the intermediate catching event is not dependent on Task 1, you can model it differently:
    image
  • If neither message is dependent on the other, you might try using CMMN to model the workflow:
    image
  • If you’re using a message queue of some sort you could place the message back on the queue and let your listener pick it back up at some point in the future.

The first two options remove the need to “park” a message/signal because the the listener is already available. The second option “parks” the message in a non-Flowable way, by relying on a message queue to do the work.

1 Like

Thank you for your response. First option has worked well for us - thank you!

hello there.
can anyone explain to me how to define the Intermediate Catching Message Event Name. is it the same thing as messageRef?

No need to crosspost (Finding executions waiting for messages based on process variable matches - #7 by joram)