Creating a BAM Application using SOA Composite
By Sudeep Agarwal on Jan 06, 2009
BAM stands for Business Activity Monitoring and it is different from Business Intelligence in that it features real-time dashboards instead of historical reports that are typical of BI applications. In this blog I will discuss underlying BAM components and also post a working sample consisting a real-time BAM dashboard that refreshes from a relational data source. As a prerequisite to building your own BAM dashboards using this example, you will need to download and install Jdev 11g TP4 as well as BAM 11g beta that comes with it. Also you must enable SOA Suite on your Jdev. For these details, refer to this link on OTN - http://www.oracle.com/technology/products/ias/bpel/techpreview/index.html
BAM uses its active data cache to display real-time dashboards. This active data cache is updated constantly by an underlying refresh mechanism and SOA Suite composite provides a powerful yet simple way of refreshing BAM cache in real-time. On the receiving end of the SOA composite is BAM’s active data cache, which consists of BAM data objects. A Data Object is like a relational table that stores data and must be refreshed constantly. And on the other end, which is the source side of the SOA composite, can be a JMS Topic, a relational schema, a web service or just good old flat files. It entirely depends on the use case you are building. In this sample, I have used a relational table as the data source. Both ends are then connected in a SOA Suite composite using an array of Technology Adapters. More will become evident about technology adapters as we go over the sample application, but to say the least, Technology Adapters are really simple to build and screen developers from many lines of code that may be required in a native application. These adapters are the main cause behind the power and ease of development of SOA Suite composite applications.
Once you are done installing and configuring BAM on Jdev 11g TP4, you are ready to create a BAM real-time dashboard using a SOA composite. To do so, I have used a database table called inventory -
CREATE TABLE "INVENTORY"
( "INVENTORY_ID" NUMBER(15,0) NOT NULL ENABLE,
"PRODUCT_ID" NUMBER(15,0) NOT NULL ENABLE,
"WAREHOUSE_ID" NUMBER(15,0) NOT NULL ENABLE,
"CREATED_BY" VARCHAR2(60) NOT NULL ENABLE,
"CREATION_DATE" DATE NOT NULL ENABLE,
"LAST_UPDATED_BY" VARCHAR2(60) NOT NULL ENABLE,
"LAST_UPDATE_DATE" DATE NOT NULL ENABLE,
"OBJECT_VERSION_ID" NUMBER(15,0) NOT NULL ENABLE,
"PRODUCT_NAME" VARCHAR2(4000) NOT NULL ENABLE,
CONSTRAINT "INVENTORY_PK" PRIMARY KEY ("INVENTORY_ID") ENABLE
Define the following trigger on the table. This trigger updates the STATUS column to modified whenever UPDATE operation is performed on the table. The reason we need this trigger will become clear when we define the database adapter in our SOA composite that polls on this database table.
CREATE OR REPLACE TRIGGER "INVENTORY_MODIFIED"
BEFORE INSERT OR UPDATE OF INVENTORY_ID, PRODUCT_ID, WAREHOUSE_ID, QUANTITY, UOM, PRODUCT_NAME ON INVENTORY
for each row
:new.STATUS := 'MODIFIED';
ALTER TRIGGER "INVENTORY_MODIFIED" ENABLE
Next we create a BAM data object and a dashboard based on the data object.
Start BAM Server (as instructed in install guidelines) and go to BAM console - http://localhost:8888/OracleBAM/default.htm Login with fmwadmin/ welcome1.
Choose Architect. Click on Create Data Object and create a layout that looks like this:
Call this data object “inventory”.
Next, we shall create a dashboard. Click on “Active Studio” on the home page. Click on “Create a new Report” and start with an empty layout. Then add a view and select Bar chart. The Bar Chart Edit panel opens up. Select the Inventory data object that you created. Next Group by “Warehouse ID” and “Product ID”. Select “Quantity” under chart values and Sum under “Summary Values”. Click Apply and Save the report.
Now that you have the report ready, we only need our refresh mechanism to update the data object. For this purpose, we create a SOA composite. Start Jdev and create a new SOA Project:
Next, drag and drop a database adapter on the left side of the composite from the component palette
Select the inventory table. Uncheck the “STATUS” column from the next step since this is not needed for the BAM Dashboard. This column will be updated by the adapter to “PROCESSED” once a row has been read. The trigger INVENTORY_MODIFIED will set STATUS column to “MODIFIED” when a row is updated. This process is called “Logical Delete”. Refer to “Oracle Technology Adapters” Documentation for further details on Polling Strategies. This can be found on here - http://www.oracle.com/technology/products/ias/bpel/techpreview/index.html
Go with all default values and Finish.
Now we need to write to the BAM data object. For this purpose, we must create a new BAM connection. New –> Connections –> BAM Connection.
Add the connection to “Application Resources”. If you create the connection under “Resource Palette”, then you must right-click and add the connection to the application. Once the connection is created, check to see if the Inventory data object shows up under the connection.
Next drag and drop a BAM adapter on the right side of the composite.
Click on Next and select the data object.
If BAM Connection doesn’t show up, you must add the BAM connection to your application.
Select UPSERT operation and click next. Select the primary key columns and shuttle them to the other side.
Click on Next until Finish. Now link both adapters to the mediator and create the XSL in the mediator. The XSL should look like this -
Save the project and deploy it on the server. Now enter values in the inventory table. In my case I have 3 Warehouses with the same set of products. The inventory levels are shown in the BAM dashboard. To open your BAM report, use the “Active Viewer”.