cancel
Showing results for 
Search instead for 
Did you mean: 

Interflow Communication

mikebrown01
Champ in-the-making
Champ in-the-making

We have two flows that collaborate with each other. We have one  process (Flow A) that progresses to a certain point and then
waits for a message from Flow B.  Flow B sends a message to Flow A and then waits for a message back from Flow A.

An example is diagramed below.



Flow A:   

Start ———————–>   Message Catch Event ———————————->   Task ———-> End
                                                               /\                                                                                              |
                                                                |                                                                        sendMessage   | 
—————————————————————————————————————- 
                                                                |   sendMessage                                                                        |
                                                                |                                                                                               |
Start  —>  Parallel Gateway  —–>  Task  ———->   Parallel Gateway  ——> End                     |
                              |                                                                          /\                                                    |
                              |                                                                           |                                                     |
                             +———-> Message Catch Event ———-+                                                     |
                                                                    /\                                                                                          |
                                                                     |                                                                                           |
                                                                    +————————————————-+
Flow B:




The problem with this,  is even though the Message Catch Event (in Flow B) is configured to always be set first,
the event is not yet in the database. So when Flow A tries to sendMessage to Flow B, it fails.

Is there a way to resolve this?  Maybe there is a different way of handling flow interactions?

5 REPLIES 5

mikebrown01
Champ in-the-making
Champ in-the-making
Here is a link to an image for the flow since I failed at formatting in the original post.

<img>
https://s3.amazonaws.com/stuff.virtualbrown.com/FlowCom.2jpg
</url>

frederikherema1
Star Contributor
Star Contributor
The main issue is that your processes do NOT get persisted until they reach a wait-state. Since you're using script-tasks, these well be executed synchronously and the actual commit will happen later on. You can try making the script-tasks asynchronous, so the process-state is persisted right before they are executed.

Another question I have is about the start of the processes. In what order are they started, and how are they started?

mikebrown01
Champ in-the-making
Champ in-the-making
<b><i>"The main issue is that your processes do NOT get persisted until they reach a wait-state"</b></i>

ok. I thought that might be the issue here.


<b><i>"You can try making the script-tasks asynchronous, so the process-state is persisted right before they are executed."</i></b>

ok. Will give this a try.


<b><i>"Another question I have is about the start of the processes. In what order are they started, and how are they started?"</i></b>

Flow A is started before Flow B.   Both flows are started programatically using runtimeService.startProcessInstanceByKey(…);

frederikherema1
Star Contributor
Star Contributor
Any chance of using a single process with a sub-process/call-activity? This might make things a bit more stable, although not 100% this would fit in the usecase you're trying to reach.

Try the async suggestion. If that doesn't work, maybe a detailed explanation of your use case might help…

mikebrown01
Champ in-the-making
Champ in-the-making
Ok setting the Task as Async is working!  I had a little bit of a problem getting it to work because the JobExecutor was turned off in the config file :0