Thursday, May 21, 2015

#403 BPM Throw Terminate - at your own risk!

Simple example -

This process is called from my order process, used in the previous post -
Note CallTerminator etc -

I deploy and test with OrderNr 123 -

So let's look at the audit trail for OrderProcess

However, according to em, the process is still running -

Not what was probably wanted!
Terminate should also not be used in parallel or inclusive gateways.

#402 BPM - Reusable Processes

So what are reusable processes in BPM?
reusable, you may say and who am I to disagree!

But there must be something more to it, right?

Let's begin with the ORCL docs -

You can invoke a process from another process using call activities. The invoked
process is a child of the process invoking it.
When you run a call activity, the engine does not create a new token for the reusable
process. The token in the parent process passes to the reusable process. When the
token completes the child process, it returns to the parent process to continue running
the activities that follow the call activity.
The child process must be a reusable process. Reusable processes can be invoked from
multiple processes. You can only start a reusable process by invoking it from a call
You cannot access reusable process from other SOA components because they are not
part of the SOA composite.
The start event of a reusable process must always be of type none. The end event can
be a error or a message event.

Here is a simple composite containing a BPM process -

As usual with my examples, it is an order process.
Sure where would we be without such?

Anyway, now I add a new BPM Process, of type
Reusable Process,  to the composite -

Input/Output as follows -

Note - you do not see the reusable process in the composite view -

Edit the Security Process and add a Human Task -

Now call this reusable process from the main order process -

Do the Data Associations, for input and output -

Some takeaways at this stage -

1. The reusable sub process does not have OOTB access to it's calling or parent process variables.
It only can see those passed as arguments. In the above case, the

2. These are not defined at the Start / End nodes of the sub-process, as you may have expected.

3. Reusable sub-processes are not exposed to the outside world. They can only be used
within composite boundaries.

Now let's deploy and test.

I approve the order -

Check out the em audit trail -

Now, I create a another BPM process -

I call it from the order process, as follows -

I deploy and test - here we see, of course, the 2 process instances

Another takeaway - the reusable sub-process runs within the "parent" process instance.
Calling another process via Send/Receive will cause separate instances to be created.

Wednesday, May 20, 2015

#401 API Manager basics


A short introduction to the product -

post #378 described how to install, let's now look at what we get.

To quote the ORCL docs -

Oracle API Manager facilitates the creation of APIs that expose functionality of
backend systems or other services. These APIs are published for use by application
developers and are managed and monitored at runtime.
API Manager is built on Oracle Service Bus. Proxy services created using Service Bus
can be published as APIs. API Curators decide which of these services should be
managed and exposed to developers. API Curators then add metadata and publish the
APIs to a developer portal, from which application developers subscribe to and view
information necessary to consume the APIs. Administrative users can use the
developer portal to monitor usage metrics and performance analytics at runtime.

Now to the roles -

API Curator: Users with this role use the Service Bus Console to curate the
metadata associated with and expose proxy services as APIs through the API
Manager Developer Portal. Users assigned this role have read-only access to the
remainder of the Service Bus Console so they can view artifact information.

API Consumer: Users with this role can use the API Manager Developer Portal to
view, subscribe to, and consume APIs. Users assigned this role have no access to
the Service Bus Console.

API Admin: Users with this role have administrative privileges for the API
Manager Developer Portal. API Admin users can view API usage metrics,
analytics information, and detailed subscription information for each User and
API. Users assigned this role have no access to the Service Bus Console.

Now that we have the general idea of what API Manager is, let's take a look at the components -

I will begin with em - because this is where you create the api manager users.

Create API Manager users in EM

Here are the roles -

Assign our new consumer user to this role -

Assign our new mgr user to this role -

API Manager Portal


login as MyAPIConsumer/welcome1

Note the 3 tabs on the right -

Logout and login as MyAPIManager/welcome1

Service Bus Console

Here I have a simple SB pipeline that routes a request to a simple credit card
validation service I created.

I edit the API values -

Once published, we can see it in the portal -

Managed/ Un-managed?

So what does this checkbox mean?

Back to the ORCL docs for an explanation -

A managed API is an access-controlled API. Per-user metrics are also available for
managed APIs. In order to successfully invoke a managed API, a user will first need to 
create an application and subscribe to a given managed API. 
The client must then invoke the API providing the API Key for the call to be successful.

Unmanaged APis can be invoked without subscription and without passing an
entitlement key at runtime.

API Subscription

Back in the portal as the consumer user -

The consumer subscribes to APIs via an Application.

Select the API -

Note the key - 9b0d5689-30b0-4b1f-bda7-09b3625348b1

#400 Using the SOA/BPM APIs to check for running instances (leveraging Sensor Values)

I have a very simple scenario here - the requirement is to be able to check whether
a process for orderNR nn is already running.

This check will be done to avoid duplicate order processing.

Here is my simple BPM process, in all its simplicity -

Just my usual BPM Order process.

I create a composite sensor on the incoming orderNr -

I create a test instance for orderNr 345 -

I use the following API code to check for running or processed instances
for that particular orderNr.

    public void findInstanceBySensorValue(String compositeName, String sensorName, String sensorValue){
        try {
            locator = this.getLocator();
        } catch (Exception e) {

        List sFilterList = new ArrayList ();
        SensorFilter sFilter =
          new SensorFilter(sensorName,
        CompositeInstanceFilter filter = new CompositeInstanceFilter();
        try {
            List compositeInstances = locator.getCompositeInstances(filter);
            System.out.println("*** Found " + compositeInstances.size() + " Composite Instances.");

        } catch (Exception e) {

    public Locator getLocator() throws Exception {
        Hashtable jndiProps = new Hashtable();
        jndiProps.put(javax.naming.Context.PROVIDER_URL, "t3://localhost:7101/soa-infra/");
        jndiProps.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
        jndiProps.put(javax.naming.Context.SECURITY_PRINCIPAL, "weblogic");
        jndiProps.put(javax.naming.Context.SECURITY_CREDENTIALS, "welcome1");
        jndiProps.put("dedicated.connection", "true");
        Locator locator = null;
        try {
            locator =;
        } catch (Exception e) {
        return locator;


My Tester -

    public static void main(String[] args) throws Exception {
        Test test = new Test();
        MyBPMClientImpl mbci = new MyBPMClientImpl();
      // mbci.getAllComposites();
        // default/BPMOrders!1.0 345
        mbci.findInstanceBySensorValue("default/BPMOrders!1.0", "OrderNrSensor", "345");

I included the following libraries -

The Tracking api jar can be found here -

JDeveloper project here

I then expose the Client class as a web service -

    public int findInstanceBySensorValue(@WebParam(name = "compositeName") String compositeName,
                                         @WebParam(name = "sensorName") String sensorName,
                                         @WebParam(name = "sensorValue") String sensorValue){
Deploy the web service and test it -

Here I am using SOAP-UI

The Request -

The Response -