Message Event that triggers only when a dynamic expression is satisfied

Is there a way, within the modeler, to catch a message event only when an expression is satisfied? In other words, I dont want a catching message event to trigger a transition every time it is received, but only when a dynamic expression (ie. an expression formed from variables set by the incoming message event) is also additionally satisfied.

Context: I am trying to see if there is a succinct way of representing the below diagram (a state machine with guard conditions)…

… in the following way, if the guard condition can be absorbed into the boundary message event:

you can use a Conditional Boundary event

Thanks @aravindhrs.

  1. It seems like conditional event gets triggered only when an expression evaluates to True, and the evaluation of that expression happens during create/update/delete of a variable. But, is there a way for conditional events to evaluate its expression only on catching a message event?

  2. The guard conditions in my case are dynamic ie. they are expressions formed from variables updated from the incoming message event. How can I do that in conditional events’ expression?

@GuSuku, You can use expressions for the name in the message event definition (except for the message start event). The name is then resolved as soon as a process reaches the scope of the message. For example when the process instances reaches a Message Intermediate Catching Event, then the expression within the name is resolved.

@aravindhrs

I am missing something and that may be entirely due to my ignorance.

Message Events have a name and a payload. The name, like you said, can be an expression formed from process variables. From this, can you help connect the dots to how I can use this to design a transition trigger that gets triggered only when a specified message event is caught and a dynamic expression formed from variables in that message’s event evaluates to True?

For an example, Event A in my diagram could be a purchase transaction event whose payload is the itemized bill, while the (dynamic) Guard Condition A could be “does this transaction include burgers among its items”.

Hi,

Have a look at my Raft Concensus State Machine demo. This may give you some inspiration…In this FSM, each process instance is in states leader, follower, election…hence as events come in, the way each process reacts depends on the state its in…

regards

Rob

Thanks @Webcyberrob. Your suggestions from a different discussion we had few months ago was how I had arrived at the first diagram in my original post above!

But now, I am trying to find if there is an succinct way of representing the combo of (event-based gateways + message/conditional events + business rule task + yes/no XOR)

That is because, users of my modeler service will make heavy use of events with guard constraints, for triggering transitions. Requiring them to use the above combo pattern each time makes it error prone and tedious.

Hi @GuSuku

No prob - you can correlate message delivery based on process variables. Hence if you can encapsulate the receiving state in process variables, then your process can subscribe to a message type but will only trigger if correlation variable conditions are met…

regards

Rob

Hi,

BTW - another option you could consider is to create a domain specific extension which could encapsulate listeners etc to simplify th modelling experience…

Modeller Templates - With this mechanism you can create domain specific languages and create a low code environment…

regards

Rob

you can correlate message delivery based on process variables. Hence if you can encapsulate the receiving state in process variables, then your process can subscribe to a message type but will only trigger if correlation variable conditions are met

Interesting. Can you elaborate more on how to achieve this? Maybe an example using the properties panel in the Modeler for Message Intermediate Catch Events?

Modeller Templates - With this mechanism you can create domain specific languages and create a low code environment

I had looked into this, but I couldn’t figure out how to combine all of (event-based gateways + message/conditional events + business rule task + yes/no XOR) into one custom task, that is also parameterizable for number of branches out of the event gateway and for types of event in each branch (event vs conditional vs timer etc). Or do you have a different solution in mind?

Thanks again, Rob!

Hi,

To use variable correlation, it could be a little ugly as it requires a ‘protocol’ between process and client. So it may not be so dynamic…It would be very similar to generating a dynamic message name, however in this case the name is static and it would rely on correlation variable names being known a priori by both message source and receiver…

Hmm - message guards are hard!

regards

Rob

I see what you mean. Extending that hint, one could also use just a plain Conditional Event (without directly listening to a Message Event), where a transition is triggered when the condition is satisfied for a variable that is directly modified by an event, as per a protocol. But ya, it may not be very dynamic, but thats an option.

On creating a custom element DSL, do you know if it is possible to combine multiple BPMN elements into a parameterizable custom element?

1 Like

Hi,

Not that Im aware of…A while back I wondered if I could do it with an unexpanded, inline subprocess, but now that the feature is removed, not worth pursuing…Another similar approach is created reusable subprocesses and deploy them to the engine as reusable components, then create a service task call or subprocess call template bound to these ‘functions as a process’…

regards

Rob

Hi @Webcyberrob,

Interesting use of subprocess as a potential “function as a process”. I looked into subprocess docs, but could not find how I could parametrize Events (A and B) and Guard Conditions. It seems like those need to be pre-defined for all instances of a subprocess?