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 Tom,

We don't have a timeframe for this feature. I do understand your use case.
Is it something you would be willing to contribute? That would speed things up.

Best regards,

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

I might be able to help contribute on this feature, but I would need some help getting pointed in the right direction.  I have yet to dabble too much into the Activiti source code. 

If you or someone else on the team could point me at the various places where the exclusive gateway is added and used inside Activiti, that would help me get started on the inclusive gateway behavior.  Also, it would be helpful to know where the logic itself to check the conditional expression on the sequence flow gets evaluated.  I'd also be interested in how to get the Inclusive Gateway added as an element in the Activiti Designer plugin for Eclipse.

If you can supply this information, I'll take a look and get an idea of the scope of the effort.  Out of curiosity, do you have an idea for the scope of the effort off the top of your head?

Thanks,
Tom

trademak
Star Contributor
Star Contributor
Hi Tom,

Great!
Feel free to contact me if you need any help on this.
The BpmnParse class is the one that parses the BPMN 2.0 XML file. So there you should add the inclusive gateway XML portion.
Then in the org.activiti.engine.impl.bpmn.behavior package you can find the various implementation classes, including the ExclusiveGatewayActivityBehavior and the ParallelGatewayActivityBehavior. The Inclusive gateway is a combination of both these gateways so the challenge would be to combine them into the new InclusiveGatewayActivityBehavior class.

Best regards,

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Then in the org.activiti.engine.impl.bpmn.behavior package you can find the various implementation classes, including the ExclusiveGatewayActivityBehavior and the ParallelGatewayActivityBehavior. The Inclusive gateway is a combination of both these gateways so the challenge would be to combine them into the new InclusiveGatewayActivityBehavior class.

Or see if a GatewayActivityBehaviour base class can be created of which they all inherit common stuff (I hate duplicate code ;-))

tidetom
Champ in-the-making
Champ in-the-making
Thanks guys, I'll take a look and get back to you.  I also requested committer status, however haven't received a response yet … though probably will need some time to take a look at the existing code and make changes before it's needed.

trademak
Star Contributor
Star Contributor
Great. If you agree I think it's better to submit a diff patch to the JIRA issue and we'll take a second look at it.
Then we can submit the patch or you can do it yourself if that's your preference.

Thanks,

tidetom
Champ in-the-making
Champ in-the-making
Sorry for my delayed reply … yes, that'd be fine to submit a patch.  I'd prefer to get a code reviewer on this anyways Smiley Happy  Thanks

tidetom
Champ in-the-making
Champ in-the-making
I've done some initial investigation into the Inclusive-OR behavior, and was wondering if you could double-check me on this…

It looks to me like the behavior for implementing Inclusive-OR actually already exists.  If you take a look at org/activiti/engine/impl/bpmn/behavior/ExclusiveGatewayActivityBehavior.java, it has the following inheritance tree and only overrides the "leave" method of the parent:

+ ExclusiveGatewayActivityBehavior
  + GatewayActivityBehavior (abstract - no implementation)
     + FlowNodeActivityBehavior
         - delegates implementation to org/activiti/engine/impl/bpmn/behavior/BpmnActivityBehavior.java

The implementation of FlowNodeActivityBehavior looks like:

/**
   * Default way of leaving a BPMN 2.0 activity: evaluate the conditions on the
   * outgoing sequence flow and take those that evaluate to true.
   */
  protected void leave(ActivityExecution execution) {
    bpmnActivityBehavior.performDefaultOutgoingBehavior(execution);
  }
 
If you take a look at the implementation of BpmnActivityBehavior#performDefaultOutgoingBehavior, it actually implements the logic that one would expect of an Inclusive-OR … it checks the condition on each outgoing transition.  If the condition evaluates to true (or if conditions are disabled) then transition will be added to the list of transitions that will be executed.  If there are multiple valid transitions, all transitions will be executed (similar to the Parallel Gateway implementation).

As it looks to me, the implementation of InclusiveGatewayActivityBehavior could simply extend from GatewayActivityBehavior and leave the implementation as-is (with no overrides).  The purpose of creating the extension would just be to support future change.

Then, the InclusiveGatewayActivityBehavior would be called from BpmnParse.java (as you mention above … this would need to be added), and everything would seem to be all set (with the exception of the designer piece).

The only further question I would have would be whether it makes sense for InclusiveGatewayActivityBehavior to have an implementation of "leaveIgnoreConditions".  I suppose ExclusiveGatewayActivityBehavior does not override this implementation, so InclusiveGatewayActivityBehavior wouldn't need to either, however I'd leave that to the experts to determine.

Any thoughts on this?

Thanks,
Tom

tidetom
Champ in-the-making
Champ in-the-making
Also, if you could point me at the JIRA item, I have a patch that includes a fix under this assumption.  I've also patched the ProcessDiagramCanvas and ProcessDiagramGenerator to programmatically draw the the inclusive gateway per the BPMN spec.