The message have information for my next task.
Visual process
My event in the bpmn file
<intermediateCatchEvent id=“attenteTraitement” name=“Attente du traitement de la demande par le Back Office”>
<messageEventDefinition id=“attenteTraitement_ED_1”
messageRef=“process:subventionInstruiteMessage”/>
</intermediateCatchEvent>
How to configure my intermediate catch event for setting usable data (with the next service task).
Last question, in java the message Receive Async api are used. It’s work for my use case ?
I don’t quite get what you are trying to achieve? Are you trying to manually (programatically) send the message event with the payload to the process or you need something else?
My first problem is how to indicate in the bpmn file what I do with the message of intermediateCatchEvent.
I want to use the data of message in the next service task.
On the technical side I use an esb that embeds the flowable engine and I wonder if its way allows to achieve what I want.
In the BPMN you only need to provide the message event definition. Have a look at the Message Event Definition section of the Flowable reference documentation.
Yes, i have the definition of event (example un 1st message).
but i want to use the content of message in service task (2nd in my screenshot).
Definition of message event
<intermediateCatchEvent id="attenteTraitement" name="Attente du traitement de la demande par le Back Office">
<messageEventDefinition id="attenteTraitement_ED_1" messageRef="process:subventionInstruiteMessage"/>
</intermediateCatchEvent>
Definition of service task (following the message event).
<serviceTask completionQuantity="1" id="informerUsagerResultatInstruction" implementation="##WebService"
isForCompensation="false"
name="Informer l'usager du résultat d'instruction" startQuantity="1"
operationRef="process:notifier">
<ioSpecification>
<dataInput itemSubjectRef="process:notifierStatusRequestItem" id="dataInputOfNotifier"/>
<dataOutput itemSubjectRef="process:notifierStatusResponseItem" id="dataOutputOfNotifier"/>
<inputSet>
<dataInputRefs>dataInputOfNotifier</dataInputRefs>
</inputSet>
<outputSet>
<dataOutputRefs>dataOutputOfNotifier</dataOutputRefs>
</outputSet>
</ioSpecification>
<dataInputAssociation>
<targetRef>dataInputOfNotifier</targetRef>
<assignment>
<!-- **I want to use the data in message of message event here **-->
<from>${statut}</from>
<to>${dataInputOfNotifier.statut}</to>
</assignment>
<assignment>
<from>${idSubvention}</from>
<to>${dataInputOfNotifier.numDemande}</to>
</assignment>
</dataInputAssociation>
</serviceTask>
The documentation does not provide a real example indicating the use of event message data (or id found).
The documentation references void messageEventReceived(String messageName, String executionId, HashMap<String, Object> processVariables); which means that you can send a message with extra variables. You can then use those variables like any other variable in the process.
I use messageEventReceivedAsync(String messageName, String executionId). This method does not exist with an extra parameter processVariables. There is a way to set process variables using this API ?
I don’t remenber why I used the asynchronous API ? Can you give us more information on differences between the synchronous and asynchronous API ?
Unfortunately, at this moment there is no way to set the properties by doing messageEventReceivedAsync. Just had a quick look at the code and there is a TODO to have support for sending a message with properties asynchronously.
The difference between the sync and async API is in the way that the message is delivered.
With the sync API the subscription is immediately picked up, send to the process and continues with the execution. The call will return once the first wait state is hit.
With the async API a job is scheduled through the job service and the handling is done in another thread without waiting for the wait state in the process.
There is a way to achieve what you need by modifying your process a bit. You can use the messageEventReceived(String messageName, String executionId, Map<String, Object> processVariables) and make sure that the first task that you have after the message in your process is async. With this you would achieve something similar to messageEventReceivedAsync.
Thanks for your explanations. I remember why I used the async API. If we use the synchronous API, tasks after the intermediate catch event will be executed until an async point is reached. In a SOA and IS urbanization point of view, it’s not a good way because we should associate a business service only to “unlock” the intermediate catch event.
What do you think about to use the API RuntimeService.setVariablesLocal(String executionId, Map<String,? extends Object> variables) ? Is it an async equivalent to messageEventReceived(String messageName, String executionId, Map<String, Object> processVariables) ?
Started reading your question again and your last example is the last that I would have proposed. It is even better than my other ones .
You can do RuntimeService#setVariablesLocal(String, Map<String, ? extends Object) and then call messageEventReceivedAsync. The variables would be set to the process. One small remark, I am not sure what you are using as a transaction layer, but in order to be sure that everything is “correct” you should use ManagementService#executeCommand, unless you are using Spring or some other abstraction that makes sure that your code is transactional as well, then you can just invoke the services.
Your last proposal is interesting. I will think about your both proposals against our business model: Should we use a choreography (consequently an intermediate catch event) or just a simple service task (consequently a triggerable service task) ?