Using Complex Gateways in Oracle BPM 11g

Starting here and in some of the forthcoming blog posts I will try to cover some basic and advanced gateway patterns in Oracle BPM Suite 11g.

This post shows how and in which scenarios do we need to use a Complex Gateway in a business processes modeled with BPMN techniques.

The Knowhow

Complex Gateways are required to synchronize N paths from M incoming transitions.  This gateway is a point in the process where M parallel (or inclusive) branches converge into it and the following activity is enabled once N incoming branches have been triggered (or their outcomes met). The result of the rest of the M minus N branches is ignored. The merge is blocked till the M incoming branches have been triggered and unblocked when their execution is completed.

Complex Gateways are rare in business process modeling but very essential to realize some very common workflow patterns. Consider for example a widely used modeling technique that supports explicit skipping of activities. Imagine how you use an OR gate to write conditions to negate the sequences that you don’t want to be executed.This is commonly referred to as dead path elimination. However, the OR join cannot be applied in all cases of dead path eliminations. The complex gateway is intended to model complex synchronization behavior. In general,firing behavior of the complex gateway is specified using an activation expression which is evaluated with the reception of every token. It might reference separate token counters for each of the directly preceding sequences. Once the activation expression evaluates to true, a token is created on the normal output flow. The gateway is also capable of aborting all pending flows and finally resets by creating a token on the optional reset output flow.

The Use Case

To process a security clearance application, a business process needs to check concurrently whether the applicant has a criminal record, is a natural citizen, and has sound credit history. The outcomes of these checks is to be evaluated in such a way that as soon as two of these checks pass and the applicant doesn’t have any criminal history, a clearance is granted, and the third check is aborted. This pattern, a special case of the N/M join.

Complex Gateway

The Security Clearance Process has three sub processes Criminal Record Check, Natural Citizen Check, and Credit History Check that are run in parallel (having been launched by the AND parallel split from Initiate Security Checks). There is also a special complex gateway element (diamond with an asterisk) to evaluate the outcome of responses coming from each of the sub processes. This is a typical example of a 2 of 3 join with one precise condition to be met.


The prerequisite to create and use the business process explained in this post you would need Oracle SOA Suite 11g PS4 or higher.

Modeling the Process

Let me begin with trying to model the business process as shown above in JDeveloper BPM Studio. It involves creating a composite project with BPMN extension and then creating a BPMN process with an asynchronous interface. The start event is a message start type that accepts personal information header to be able to process security clearance for an individual.


The next step involves creating a gateway of complex type in the business process and changing its type to “Parallel and Complex”. From the parallel arm create three sub processes that converge to the gateway merge.


Each of the sub processes are implemented to invoke a service that takes in the personal information of an individual and returns a corresponding response. For example, there is a criminal check service that returns the crime history and all available crime records for an individual based on his SSN. These services are mocked to be able to execute the process and are packaged in a WAR file (Complex Gateway Services).

The way i chose to implement each of the sub process is decouple them from the validation services totally.  Raise an event to check an individual’s crime history and then let another process subscribe to it (implemented with BPEL). The BPEL process then invokes any number of services to gather the crime records and finally publishes a status event by itself too.  The original sub process then have an intermediate mid process receive event that subscribes to the validation status, correlates and ends. Don’t worry too much if you do not get what is explained. You can import the process (application) being discussed from the link here.


The GetCrimeHistory mock service is returns a list of criminal records (if they exists) and a Boolean flag called recordExists (true if SSN begins with 1, false otherwise).

The other two sub processes are implemented in the exact way, only they invoke a different set of services to check the status of citizenship and  obtain a credit history for an applicant.

What is of typical importance is the Gateway Merge point that evaluates the outcome/results of these sub processes. Now as per the use case, there are two checks to be evaluated to go ahead further down the process, 1.) confirm whether there is any record of crime existing for the applicant 2.) get a valid approval check response from either the credit history check or citizenship status check sub processes.

The first condition is enforced with the expression crimeSummary.recordExists==false. The logic for the second condition is provided by checking the value of the activationCount variable (predefined). This variable holds the value of tokens being received at the merge gateway. As per the expression below, if at least two tokens are received then the process is good to move ahead. The checkbox to Abort pending flows ensures that when the flow control moves ahead after receiving the required tokens, all pending sequence flows are abruptly cancelled (This can be perceived as dead path elimination without writing a negation condition on any of the sequence flows).


Executing the Process

Deploy the completed process to the BPM infrastructure as a composite application. From the Enterprise Manager console navigate to the deployed composite dashboard. Since the business process had a message start event, it can be exposed as a standard service. The Test button on the composite dashboard can be used to test the composite application.

Test 1 : Criminal Record is Present

Create a test request for the composite operation so that the criminal record status flag is returned to be true(Value of input SSN to begin with 1). Invoke the service and wait to let the execution complete. Lunch the audit trail to analyze what happens and how does the gateway evaluates the sequences.


The process executes in entirety and is successfully completed. However to examine the behavior of the gateway we would need to see the instance flow trace of the BPMN component.

The Intiate Security Checks gateway is denoted as a parallel splitter and spawns three independent threads to executes sequences originating from it concurrently. The event status of each of the thread is Thread Completed. Wonder why all the three threads executed when the gateway merge was supposed to get going even when two tokens were sufficient? Well this is because the gateway expected a true value of crime summary flag. Since the flag returned was false, it lets all sequences complete in the hope that it may receive a true flag from may be some other sequence.

Lesson Learnt : It is important to design your Complex Gateways effectively in order for them to function in a true N/M way. If you put more restricting conditions, it might as well behave as a normal split-join one.  

Expand the merge gateway marked as Clearance Checks and see the XML payload. Every time a sequence flow is executed and it reaches the gateway merge the gateway exit expression is evaluated.

The first evaluation has to always fail since the merge needs at least two tokens. If the second token arrives from the Crime Check sequence, the merge gateway is again evaluated. The first condition is met as two tokens have arrived but since the a criminal record exists, the expression again evaluates to false. The flow cannot move forward since another sequence is still being executed (which eventually again will not meet the second condition in the expression).


Test 2 : Criminal Record is Absent

Now assuming if the process is tested in such a way this time that the response of the Criminal Check sub process evaluates to a false (SSN value not starting with 1), the execution trace of the instance will be starkly different from the case above. Look into the BPMN flow trace, and this time you may very well find that the merge gateway goes ahead just after getting tokens from any two sequence flows. And the pending sequence is cancelled as the gateway expression has evaluated to true. In the instance execution trace being shown below carefully examine how the Credit Check thread is marked as Cancelled as the flow result evaluates to true. This is pretty neat as the process was able to successfully implement a N/M dead path elimination using a complex gateway (depending on sequence execution outcome).


This concludes this article that explains the usage of complex gateways in Oracle BPM Suite 11g. In the forthcoming posts, I shall describe other patterns and usage of Event based gateways.

More Relevant Use Cases

Now if you are wondering whether the example used in this post is too hypothetical and there would seldom be a case or a need in your business process to have a complex gateway that eliminates dead paths depending upon outcomes rather than negation logic in the flow sequences. Perhaps it is time to think over.

Order Complex Gateway

Imagine the scenario explained above, arising when a business process is trying to orchestrate Order booking. The process is initiated with order headers and the business it needs to fetch customer data and order details to continue processing. The customer information may be available in an intermediate cache or certainly in the master customer data hub.

See how again using a complex gateway in this scenario is helpful!

The Source Code and Relevant Files

The JDeveloper application used in the article can be downloaded from the link contained here.

10 thoughts on “Using Complex Gateways in Oracle BPM 11g

    • I don’t think you could use an inclusive gateway here. The inclusive gateway basically waits for all tokens that are still out there and can arrive at this gateway. So in this case it would always wait for all three tokens and it would not take into account that in some cases the clearance can already be granted after two checks (criminal negative, one of the other checks positive).


  1. wrt your Security Clearance Process — I think I’d model it differently

    1) the Security Clearance Process itself should be ‘time-boxed’ – if it doesn’t complete within xDays then an exception handling event should be triggered

    2) I assume that the 3 sub-processes (Criminal Record Check, Natural Citizen Check, and Credit History Check) are performed by other Roles in your business — as such I’d use Signals/Events to initiate/communicate results —
    Your Security Clearance Process triggers the 3 sub-Processes & waits for a check_OK signal from EITHER the Natural Citizen Check or the Credit History Check — Having got one of these your main process can now wait for a check_OK signal from the Criminal Record Check (which may have already arrived) and you have your result

    By waiting for a check_OK signal your process will ONLY move forward based on successful outcomes or will eventually timeout


    • Agreed. The modelling is just indicative and the actual modelling of the process may have much more. The process is examplified with a very basic and simple use case to highlight the usage of complex gateways.

      But your comments are highly appreciated as they throw a lot of fresh perspective here.



  2. The “abort pending flows” option is a useful feature, but I think this may be a proprietary extension, because I can’t find anything in the BPMN specification about complex gateways aborting pending flows. So I assume that according to the standard, in your model the third check would still be performed even when it wasn’t necessary any more.


  3. I just tried to send another comment to where an alternative model is proposed.

    However, the system wouldn’t let me send another comment, probably several comments from one IP are treated as Spam.

    Here’s my suggestion based on Tom’s proposal:

    The clearance can be granted if the criminal record is okay and one of the other checks is possible.
    Therefore, a criminal record that is not okay cancels the outer sub-process.

    If one of the other checks is successful, the escalation end event cancels the inner sub-process, since the other check is not required any more.

    If both other checks are performed and they are both negative, the inner sub-process reaches the end-event. In this case, the clearance also must be refused, so the outer sub-process is canceled (the criminal record check is not required any more).

    I hope that represents the process correctly. The logic is now explicit. However, I must admit that this model looks quite complex, and most business users I know would not understand this model, but many of them would be okay with Arun’s model.



    • Needless to write it again. I can see that Tom has already updated his blog with the design that you have suggested and I think now that the final redesign actually covers the original use case that i was trying to cover.
      Thanks to both you and Tom for deliberating further here.


  4. Pingback: Understanding Event Based Gateways in Oracle BPM Suite 11g « Oracle Technologies Premier

  5. How do you handle if the criminal records are negative. Shouldn’t some end event be signaled? I know it’s handled in the other design shown in the comments, but in case of Complex gateway, how is it handled if the gateway is never activated.

    Sorry if the question is a stupid one.


If you have any comments, suggestions or feedback about the post, please feel free to type it here and I will do my best to address them asap

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s