Multi-instance mail service

Hi,
I’ve been trying to implement a service task that sends a message to more than one receiver. I know that I could send only one message to more than one mail address. However, what I want to do is to test multi-instance sending messages in parallel. I searched a similar questions in the forum but I couldn’t find any implementation for the flowable-modeler application.

What I did in the picture I attach below is to define a collection wih 2 mails. My intention is to send 2 different messages, each one to one of the mails in the collection.
So my question is: what should I define in the “Collection (Multi-instance)” , “element variable (multi-instance)” and “To:” field?
With the below implementation the process never begins, when I click the “Start process” button in flowable-task application nothing happens.

diagram1

Thanks.

Hi,

You would need to leave the Cardinality field empty and instead of providing the collection statically it would be good to use a process variable or a spring bean to resolve the list of email addresses.

Best regards,

Tijs

2 Likes

Thanks Tijs,

So I understand that to build a multi-instance process I need to use Eclipse (or a similar tool) to assign the collection. Am I wrong?
Once I have the collection defined, the variable element should be the one I defined in the “To:” field? I saw a similar example in the documentation where the variable element was “assignee”.

Thanks,
Clara

Hi Clara,

It’s discouraged to hard code these kind of values in your process definition, because a change in these kind of values would mean deploying a new process definition. It’s better to keep these values in a configuration file that can be easily changed. You can still use the Flowable Modeler to define the collection variable / expression, no need for Eclipse. But you will have to define the configuration file and expose it in a Spring bean to be able to use it in a collection expression.

Yes, the To variable is correct indeed, it refers to the element variable you defined.

Best regards,

Tijs

1 Like

Thanks for the quick response and thanks for the help too. I’m starting to work with Flowable and I’ve got many questions. :slight_smile: