Exploring the WebLogic Integration 8.1 RDBMS Event Generator
Pages: 1, 2, 3

Creating Consumers to Message Broker Channel

Now that we have created our event generator, let's look at creating a consumer for the Message Broker Channel. Here are the steps you need to follow.

After opening WebLogic Workshop, click File ->New -> Application. Select Process Application, and then name the application InventoryOrder, as shown in Figure 2:

Step1
Figure 2. The first step in creating a consumer for the Message Broker Channel

Select the Schema folder from the application. Right-click the folder, select New -> Channel File, and then name the file InventoryEvent.channel, as shown in Figure 3.

Step2
Figure 3. The second step in creating a consumer for the Message Broker Channel

Open the InventoryEvent.channel file and make a new XML Channel, as specified in Figure 4, to receive the XML messages through the event generator: (click the image for a larger view).

Step3
Figure 4. The third step in creating a consumer for the Message Broker Channel

Click the Starting Event node, and then choose the option to subscribe to a Message Broker Channel and start via an event, as shown in Figure 5.

step4
Figure 5. The fourth step in creating a consumer for the Message Broker Channel

Double-click the Node subscription and select the channel to subscribe from the available drop-down menu.

Step5
Figure 6. The fifth step in creating a consumer for the Message Broker Channel

Select Receive data, and then choose Variable Assignment. Use the "Select variables to assign dropdown" to create a new variable of type XmlObject, and then assign the XML coming in through the channel to the newly created variable, as shown in Figure 7.

Step6
Figure 7. The sixth step in creating a consumer for the Message Broker Channel

Drag a Perform node from the Process Node palette, and place it between the Subscription and the Final node. Name the Perform node PrintInputXml, as shown in Figure 8.

Step7
Figure 8. The seventh step in creating a consumer for the Message Broker Channel

Click the Perform node to open the following pop-up and select the view code, as shown in Figure 9.

Step8
Figure 9. The eighth step in creating a consumer for the Message Broker Channel

Add this block of code to the code section of the Perform node of the Process Definition File (JPD):

public void perform() throws Exception {

  System.out.println("Incoming Xml is" +

  this.inputEventXml.xmlText());

}

This application will print the XML being published into the Message Broker Channel by WebLogic Integration according to the events raised from the database (in our example when the quantity on hand becomes less than 10).

Deploying and Running the Application

  1. Select Build -> Build Application
  2. Once the application is built successfully, select the Process Definition File (JPD).
  3. Select Debug -> Start.

As soon as the application is started, a JDI proxy gets attached. It's now time for the RDBMS Event Generator to act on the database events and make the application aware of these events by publishing messages to the Message Broker Channel to which the application is subscribed.

To generate this event, make an update to the database in such a way that the inventory quantity on hand becomes less than 10. For example, if the quantity on hand is 11 currently in the database, run the following query to generate this event for Ordering Fresh Stock:

UPDATE INVENTORY SET 

 QTY_ON_HAND = QTY_ON_HAND - 2 

 WHERE PRODUCT_ID=2;

As soon as the above query is run in the database, it will invoke the trigger created, as per the steps mentioned above, to insert a record into the Shadow table. Once the changes are committed to the database, it will trigger the RDBMS event and publish the data in the form of XML by fetching records from the Shadow table.

The XML posted to the Message Broker will appear as follows:

INCOMING XML IS<TABLEROWSET XSI:SCHEMALOCATION=

   "HTTP://WWW.BEA.COM/WLI/RDBMS_EG/INVENTORY 

   TABLEROWSET.XSD"XMLNS:XSI="HTTP://WWW.W3.ORG/2001/

   XMLSCHEMA-INSTANCE" XMLNS:WLD=

   "HTTP://WWW.BEA.COM/2002/10/WEBLOGICDATA" 

   XMLNS="HTTP://WWW.BEA.COM/WLI/RDBMS_EG/INVENTORY">

   <TABLEROWWLD:ROWID="0"WLD:ROWSTATE="INSERTED">

   <PRODUCT_ID>1</PRODUCT_ID><OLD_PRODUCT_ID>1

   </OLD_PRODUCT_ID><QTY_ON_HAND>9</QTY_ON_HAND>

   <OLD_QTY_ON_HAND>10</OLD_QTY_ON_HAND>

   <QTY_ON_ORDER>10</QTY_ON_ORDER><OLD_QTY_ON_ORDER>

   10</OLD_QTY_ON_ORDER><COST>100</COST><OLD_COST>100

   </OLD_COST></TABLEROW></TABLEROWSET>

Summary

WebLogic Integration's RDBMS Event Generator provides a convenient and simple way of integrating databases with enterprise applications by making use of the asynchronous retrieval of messages from the database. This article explores the possibility of customizing the RDBMS Event Generator following the business requirements within an enterprise. In addition, this article focuses on giving you detailed explanation of WebLogic Integration's RDBMS Event Generator implementation and how to effectively exploit the features provided by the RDBMS Event Generator.

Mahadevan Krishnan is a graduate in Information Technology. He has more than three years of experience in IT industry and is currently working with Verizon, Chennai.