cancel
Showing results for 
Search instead for 
Did you mean: 

Inclusive Gateway Support?

tidetom
Champ in-the-making
Champ in-the-making
Hello,

I was wondering if anyone has an idea of when the Inclusive Gateway will be available for use in Activiti?  Currently we can use a Parallel Gateway, however any conditionExpressions placed on outgoing sequenceFlows from the Parallel Gateway are not evaluated.  This forces us to put an Exclusive Gateway after our Parallel Gateway in order for the expressions to get evaluated properly. 

While this may seem like a worthy workaround, when you have any more than a couple possible output paths, this process becomes tedious, and more importantly takes away one of the main reasons we love Activiti so much – it's ability to give us visibility into our business processes – because the processes get very cluttered with a mess of exclusive gateways. (note, it is not uncommon for us to have 15-20 possible conditional paths out of a gateway, thus the cluttering).

If anyone could answer regarding a timeframe for inclusive gateway support, or if there's a different workaround that I'm not considering, please let me know.  I'd love to be able to clean up our process flows and switch over to an inclusive gateway.

Thanks,
Tom
23 REPLIES 23

trademak
Star Contributor
Star Contributor
Hi,

I think your description of the inclusive gatway is correct.
Did you write unit tests to test this implementation?
You can create the JIRA issue yourself and attach a path if you have one available.

Thanks,

tidetom
Champ in-the-making
Champ in-the-making
I'll be working on some unit tests in the next couple of days.  I was also planning on looking into the designer piece of inclusive gateway.

I've created a JIRA issue to track the effort: http://jira.codehaus.org/browse/ACT-890 and submit patches against.

tidetom
Champ in-the-making
Champ in-the-making
Hi Tijs,

I've submitted a patch to http://jira.codehaus.org/browse/ACT-890 which contains support for Inclusive Gateway in the Activiti engine.  I did not do any code for the designer, however it would seem that someone has already started on an Inclusive Gateway for the designer based upon the designer source code.  If you need me to look into that further, let me know.

I did end up adding some specific behavior to the Inclusive Gateway Behavior because the error handling in the default code simply ended execution when a path couldn't be found after logging a FINE level log message.  I wanted to be consistent with Exclusive Gateway Behavior, and instead fail the execution with an ActivitiException.  You'll see, however, that I've kept existing functionality consistent with the implementation for anyone using the old code.

NOTE: I used the Activiti project's specific Eclipse code formatter, and unfortunately some of the old code had not been formatted with it … so the diff is a little bit unwieldy for some of the files.  As long as it's applied soon, it shouldn't cause any problems.

Let me know how the integration goes…

Thanks,
Tom

trademak
Star Contributor
Star Contributor
Hi Tom,

I already had a quick look at the patch and it's looking good. We'll be looking at it more thoroughly today and update the JIRA.
How did you see that someone is working on Inclusive gateway support in the Designer?

Best regards,

tidetom
Champ in-the-making
Champ in-the-making
I must have run my query incorrectly (to find "Inclusive*" code inside the designer project).  Re-running the query now I don't see any code in the designer for Inclusive Gateway behavior.  Sorry about that — probably had started the query from the wrong location.

I can take a look into the designer piece if you'd like, but likely will not be able to start until next week or the week after due to schedule constraints.

Let me know what you think…

Thanks,
Tom

trademak
Star Contributor
Star Contributor
Hi Tom,

Unfortunately we won't be able to include the inclusive gateway in Activiti 5.7 because we already have a code freeze.
But we'll make sure it's included in the next release (5.8). Also, before the end of this month it'll be included in the trunk, so you can already use the source code.

If you'll be able to look into the Designer support that's great.

Best regards,

tidetom
Champ in-the-making
Champ in-the-making
Hi Tijs,

That's fine on the time frame.  I spent a little time and put together some patches for adding Inclusive Gateway behavior to the designer.  This is my first experience working with the designer, but I think most things went smoothly.  I wasn't able to test the code, though, so would appreciate your help in testing it after applying the patch.  The main class needing review/testing is AddInclusiveGatewayFeature in the org.activiti.designer.gui project, I drew the circle in the center of the polygon to the best of my knowledge, but haven't worked with Graphiti before and can't be sure that it worked correctly.

I've put the patches in ACT-890: http://jira.codehaus.org/browse/ACT-890

Let me know how it goes…

Thanks,
Tom

jbarrez
Star Contributor
Star Contributor
Tom,

I took a look at your patch for the inclusive gateway as committed by Tijs. It's however hard to see how the implementation matches with what the spec says:

The Inclusive Gateway is activated if
• At least one incoming Sequence Flow has at least one token and
• For every directed path formed by sequence flow that
- starts with a Sequence Flow f of the diagram that has a token,
- ends with an incoming Sequence Flow of the inclusive gateway that has no token, and
- does not visit the Inclusive Gateway,
• There is also a directed path formed by Sequence Flow that - starts with ,
- ends with an incoming Sequence Flow of the inclusive gateway that has a token, and
- does not visit the Inclusive Gateway.
Upon execution, a token is consumed from each incoming Sequence Flow that has a token. A token will be produced on some of the outgoing Sequence Flows.
In order to determine the outgoing Sequence Flows that receive a token, all conditions on the outgoing Sequence Flows are evaluated. The eval- uation does not have to respect a certain order. For every condition which evaluates to true, a token MUST be passed on the respective Sequence Flow.
If and only if none of the conditions evaluates to true, the token is passed on the default Sequence Flow.
In case all conditions evaluate to false and a default flow has not been specified, the Inclusive Gateway throws an exception.

The last part of the spec is satisfied by changing the bpmnactivitybehavior (by throwing an exception).
However, I do not see how the tokens are checked on reachability of the gateway. Can you shed some light on this?

tidetom
Champ in-the-making
Champ in-the-making
Joram,

Thanks for looking at the code.  As mentioned in an earlier post, I'm very new to the Activiti source code (first code check-in) and think a code review is very necessary to make sure I didn't miss anything. (in other words, I claim ignorance  Smiley Happy)

I used ExclusiveGateway as my template, and based upon the specification description below, I think I handled all of this section of the specification:

Upon execution, a token is consumed from each incoming Sequence Flow that has a token. A token will be produced on some of the outgoing Sequence Flows.  In order to determine the outgoing Sequence Flows that receive a token, all conditions on the outgoing Sequence Flows are evaluated. The evaluation does not have to respect a certain order. For every condition which evaluates to true, a token MUST be passed on the respective Sequence Flow.
If and only if none of the conditions evaluates to true, the token is passed on the default Sequence Flow.
In case all conditions evaluate to false and a default flow has not been specified, the Inclusive Gateway throws an exception.

However, I did not look on the "reachability of the gateway", as you mention, probably because it's not handled by ExclusiveGateway (unless I missed it).  In the source, it looked like reachability was handled somewhere outside of the "behavior".  Regardless, based on the specification, I would expect that the following segment still needs to be verified / fixed before the release of inclusive gateway by someone like yourself that has more experience in the Activiti source code:

The Inclusive Gateway is activated if
1. At least one incoming Sequence Flow has at least one token and
   a. For every directed path formed by sequence flow that starts with a Sequence Flow f
      of the diagram that has a token, ends with an incoming Sequence Flow of the inclusive
      gateway that has no token, and does not visit the Inclusive Gateway,
   b. There is also a directed path formed by Sequence Flow that starts with , ends with
      an incoming Sequence Flow of the inclusive gateway that has a token, and does not
      visit the Inclusive Gateway.

I'd be interested to know where this code goes, and if you can point me in the right direction as to where I can evaluate the incoming sequence flows, I'd be more than willing to look into a solution.

Thanks,
Tom

tidetom
Champ in-the-making
Champ in-the-making
I see that my implementation was very simplistic and only works for "downstream" inclusive behavior.  Activation does not work properly when handling upstream sequence flows after reading more on the inclusive gateway behavior here:

http://www.itu.dk/people/maca/papers/CCH10.pdf

I'll likely need some help with implementing the above behavior, as I simply don't know the Activiti APIs well enough to look upstream for potential token-based activation of sequence flows, and to protect against race-conditions in the activation of the inclusive gateway.  Willing to learn though if anyone can point me in the right direction…

Sorry for the confusion.

Tom