Best way to aggregate messages

What is a best way to aggregate messages from processes
I have process that waiting for concrete number of messages from other processes (huge number) and then continue
for example

This BPMN works extremely slow
I try to make BPMN without timer but it does not work at all. (only first event arrived and others have errors)

@tsvetval where are your “huge number” of messages being caught? Which event?

Based on your description, the diagram does not seem to work.

How about something like this

Use a business key or some process variable to represent your UUID. So when you receive messages at the Message Start Event, there is a UUID that you can link back with the process that is waiting for a completion message.

In the Check If X number of Messages have been Received Script task, this would be a query against the Runtime API (Java API) to do a count of the number of process instances running of the Message Start Event process with a process variable (or business key) they matches the UUID.

Other interesting angle is that this model would like you receive messages even before the top process is started.

If you changed the Receive Message Start Event to a none Start Event and look at: Limit number of concurrently running instances of a process definition - #4 by StephenOTT, you could make it so that the Receive Message Process wont accept “messages” until the parent process has been started with the UUID that is found in the message.

Hi,
the best solution depends on many factors. Basically what exceptions are you anticipating and in what situation you will be using the process. I created other way of aggregation of incoming messages, with event-based sub-process messages.bpmn (18.0 KB)
It is preconfigured with default values in all variables but you can play with it.

If you have any questions, ask :slight_smile:

Cheers,
Lukas

@lhofer87 - could you explain for me how this works please. the logic is confusing for me.

thanks

Hi Greco,
It is just an example, so don’t accept it as one and only “solution”.

Could you please be more specific that exactly is confusing?

In any case, there are two processes:

  1. Waiting process
  2. Sending process

The waiting process will be the “collector” of the messages that “someone” sends. When the waiting process starts, it will wait for confirmation that it has received enought messages (in reality there would be an absolut number) there is an assumption that this would not take more than 1 hour.
Next there is an event based subproces for the receiving of the messages and it has to know how many messages will come, here is one thing wrong: the message from subproces to main process - this is not right, but you can easily fix it with different construction (escalation).

The sending process represents “someone” who is sending that messeges it is just for tests and visualization.

Hope this helps.
Cheers
Lukas