How to listen for messages defined at runtime?

Hi,

I’m struggling how to define a process definition capable listening to a message that I define at runtime.

Use case: We need to split the messages into different groups controlling different environments. Due to the nature of tasks, one process instance will not be able to take care of the full load of all requests for all environments. Still all the logic will be the same.
With one hard coded “Message Name” defined in the BPMN, this works perfectly, however dynamically resolving a message name using expressions is not supported.
I attached a bpmn just to illustrate what I want to achieve.
dynamicMessage.bpmn (3.1 KB)

Did anybody solve a similar problem in another way?

I want to avoid having to modify the BPMN files before deployment. This might be possible but seems very ugly and hard for execute for operators.

Thanks,
Werner

The only way to achieve your goal that I can think of is that you use business key for correlation. Set the messageName to a fix value and use different business keys on instantiation an on message delivery.

Cheers,
Gonzalo.

Thanks for the quick reply.
We work with generated start forms most of the time (completely self-contained bpmn files are very easy to handle in operations). Unfortunately they do not support setting business keys…
But I agree, Adding a custom start form for this might already be much cleaner than manipulating the bpmn coming out of the build.

Thanks,
Werner

Hi Werner,

since expressions are not supported for message name, you can implement it by your own. For example, use a BpmnParseListener to create or modify the EventSubscriptionDeclaration of the receive task.

You can also provide a pull request to support dynamic message names (i.e. expressions) for receive task. I think it can be useful for some people.

Greetings,
Philipp

Hi Phillipp,

thanks a lot for the details :slight_smile: trying to find out if our problem was more or less unique, was one of the reasons for opening the thread. And if others had found workarounds. Using BusinessKeys is surely one potential work-around to at least group by instance.

As moving to dynamically changing message receiving might be very powerful but confusing some people as well.

I’ll talk to my team and see if we can place something in our backlog in the future.

Thanks,
Werner