cancel
Showing results for 
Search instead for 
Did you mean: 

Sending and receiving messages (Data handling in BPMN 2.0)

olfa1
Champ in-the-making
Champ in-the-making
Hello,

I want to send and receive a message from one process to another.
Since intermediate throw event is not yet supported, I used a send Task in the first process and an intermediate catch event in the other process.

I defined also the collaboration part in order to send messages through message flows (see closed file).

The deployment is already done.
However, in the execution I can't get the message in the second process.
Could you please tell me the problem?

Yours,
Olfa
6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
In the BPMN, I don't see any place where a message is sent, only a webservice-invocation. As an alternative to a message-event, you can use an intermediate throwing signal event (which is supported) and set the "scope" of the throwing event to NOT be process-instance local. This way, the throwing event will be fired throughout the engine, based on the signal-name.

Do this by declaring activiti:scope="global" on the signal-element in your XML (in both thowing and receiving BPMN's).

olfa1
Champ in-the-making
Champ in-the-making
Hello,

I tried with signals and it works.
But I want to carry data with messages.

frederikherema1
Star Contributor
Star Contributor
If you signal/message through the API, you can pass in a payload. This payload are a map of variables variables will be set on the execution, before signal/message is received…

I didn't understand what do you mean by signal/message through the API.
Can you clarify it please with an example.
Thank you very much

iceman20
Champ in-the-making
Champ in-the-making
Hi!
I am trying to do the same thing using the Explorer and modeler. Unfortunately there is no message throwing element and I cannot use the xml editing approach because the editor trims it out.

I did manage to send a signal with info in it by running the receiving process with a signal catching task first and getting its id from ACT_HI_ACTINST and then injecting it into a Service task and calling signal method. This is what the code looks like in the delegate java class:

RuntimeService rs = execution.getEngineServices().getRuntimeService();
String signalToSendTo = sendTo.getExpressionText();
Map params = new HashMap<>();
params.put("message", message.getExpressionText());
rs.signal(signalToSendTo, params);

This is a workaround for the message throwing task, but since you have to get the destination's id manually this approach is also not good.

Could you please help me with this matter?

Many thanks!

PS: when will the message throwing event will be available in the editor? The New Feature entry in Jira (http://jira.codehaus.org/browse/ACT-460) has the Fix Version set to "Later".

frederikherema1
Star Contributor
Star Contributor
Olfa, messaging through API is possible by calling runtimeService.messageEventReceived(…) allowing you to specify which execution and which message was received.

iceman20, you could use a service-task that uses the DelegateExpression's EngineServices to trigger a message-event through the API, although this might not work in all circumstances (state of current execution is not yet persisted, this can be overcome by making the service-task asynchronous). If you need to have the "messageName" configurable, take a look at field injection in JavaDelegates (see userguide), which allows you to specify a value in the BPMN-xml which can be used in your service-task.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.