RDBMS Event Generator User Guide

     Previous  Next    Open TOC in new window  Open Index in new window  View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Creating a Data Source

Before you can create RDBMS events and define channel rules for your new events, you must create a data source that points to the database and hence the Table on which the channel rule (Event) will be defined. For more information on defining channel rules for RDBMS Event Generators, see “Defining Channel Rules for a RDBMS Event Generator” in Managing Oracle WebLogic Integration Solutions

After you create your data source, you must also create the message broker channels that the RDBMS event publishes to, before you can define channel rules for any RDBMS events.

The following sections detail how you create a data source and message broker channels:

 


Creating a Data Source

Before you create a data source, you must be aware of the database connection parameters for the data source you want to connect to. If you are unaware of the database connection parameters, contact your system administrator.

Creating your Data Source Connection

The next step in creating a data source is creating the connection that you will use to connect to the data source.

To create a data source connection:
  1. Start the Oracle WebLogic Server using the startWebLogic.cmd command or from Oracle Workshop for WebLogic.
  2. Launch the Oracle WebLogic Server Console by entering http://localhost:7001/console in a Web browser or by going to the start menu and selecting All Programs > Oracle WebLogic > Workshop > Examples > WebLogic Server Admin Console.
  3. Enter your username and password and click Log In. “weblogic” is the default username and password.
  4. The Oracle WebLogic Server home page is displayed, as shown in Figure 3-1.

    Figure 3-1 Oracle WebLogic Server Administration Console


    Oracle WebLogic Server Administration Console

  5. Under Services, in the Domain Configuration section, go to JDBC and click Data Sources.
  6. The Summary of JDBC Data Sources page is displayed.

  7. Click New under Data Sources
  8. The Create a New JDBC Data Source page is displayed, as shown in Figure 3-2

    Figure 3-2 New JDBC Data Source


    New JDBC Data Source

  9. Do the following:
    • Enter a name for your connection in the Name field.
    • Note: If you want to configure a trigger type event, it is recommended that the database account username you enter in the Database User Name field is the same as the schema name of the table on which you want to configure the trigger type event. The account name you use must also have permission to CREATE/DROP tables and triggers. If you are configuring an Oracle database, the account name you use must also have permission to CREATE/DROP tables, triggers, and sequences.
    • Enter a JNDI Name for your connection.
    • Select the database type that you are going to connect to from the Database Type drop-down list.
    • For a list of the supported databases, see Supported Databases.

    • Select the database driver you want to use from the Database Driver drop-down list.
    • Note: Oracle WebLogic Server JDBC certified drivers are marked with *(asterisk).
    • Click Next.
    • The Transaction Options page is displayed, as shown in Figure 3-3.

      Figure 3-3 Transaction Options


      Transaction Options

  10. Click Next.
  11. The Connection Properties page appears as shown in Figure 3-4.

    Figure 3-4 Connection Properties


    Connection Properties

  12. Enter the required parameters in the Connection Properties and click Next.
  13. The Test database Connection page is displayed, as shown in Figure 3-5.

    Figure 3-5 Test Database Connection


    Test Database Connection

    The fields that appear on this page depend on the database and driver selected on the previous page.

  14. Make sure the details displayed on this page are correct and click Test Configuration.
  15. It is recommended that you test the driver configuration before proceeding to the next step. If you do not test the driver configuration and you have made an error in the previous steps, you will not be able to connect to the required database when you try to configure your RDBMS Event Generator.

    An error message will appear at the top of the page if there is a problem with your connection settings.

    When your configuration passes the test, the Server page is displayed as shown in Figure 3-6.

    Figure 3-6 Select Server


    Select Server

  16. If there are more than one servers in the domain you specified, select the check box next to the server on which you want to deploy the data source connection and click Finish.
  17. Note: Similarly, if there are more than one clusters, select the check box next to the cluster on which you want to deploy the data source connection and click Finish.

    The data source connection is created and deployed and you are returned to the JDBC Connection Pools page.

  18. Click Activate Change.

 


Notes on Creating a Data Source

You should consider the following when you create a data source:

 


Creating Message Broker Channels

This section describes how you create the message broker channels that your RDBMS Event Generator will publish to. You need to create three different types of message broker channel:

To create message broker channels:
  1. Start Oracle Workshop for WebLogic and ensure that the server is running.
  2. From the Oracle Workshop for WebLogic, Click FileArrow symbolNewArrow symbolOther.... The Select a Wizard dialog box is displayed.
  3. Expand WebLogic Integration and select Process Application and click Next.
  4. In the Process Application dialog box, type the details as shown in the following example:
    1. In the EAR Project Name field, enter RDBMS_ExampleEAR.
    2. In the Web Project Name field, enter RDBMS_ExampleWeb.
    3. In the Utility Project Name field, enter RDBMS_ExampleUtilty.
  5. Select Add WebLogic Integration System and Control Schemas in Utility Project check box.
  6. This adds the schemas to the Utility Project/schemas folder.

  7. Click Finish.
  8. In the Package Explorer pane, right-click the Schemas folder and select NewArrow symbolChannel Definitions as shown in Figure 3-7.
  9. Figure 3-7 Channel Definitions


    Channel Definitions

  10. The New Channel Definitions wizard dialog box is displayed.
  11. Select the SRC folder under RDBMS_ExampleUtility and enter a name for the channel definition file in the File name and click Finish.
  12. The code for the new channel is displayed.

  13. If you have a pre-configured XML channel file, replace the code for the newly created channel with your own custom code. If you do not have your own custom code, you can use the code displayed below:
  14. <?xml version="1.0"?> 
    <!--
    	 A sample channel file 
    	 Change "channelPrefix" and <channel/> elements to customize 
    	 The following namespaces are used in this sample file. These 
    	 namespaces refer to schemas that must be present in a schema 
    	 directory. 
    -	 xmlns:eg=http://www.bea.com/wli/eventGenerator" is used 
    	 for event generator metadata references 
    -	 xmlns:dp="http://www.bea.com/wli/control/dynamicProperties" is 
    	 used by the file event generator to pass payload for pass-by-filename 
    -	 xmlns:oagpo="http://www.openapplications.org/003_process_po_007" is used for a sample payload description 
    --> 
    <channels xmlns="http://www.bea.com/wli/broker/channelfile" 
    		 channelPrefix="/SamplePrefix" 
    		 xmlns:eg="http://www.bea.com/wli/eventGenerator" 
    		 xmlns:dp="http://www.bea.com/wli/control/dynamicProperties" 
    		 xmlns:oagpo="http://www.openapplications.org/003_process_po_007"> 
    	 <channel name ="Samples" messageType="none"> 
    		 <!-- A simple channel passing XML --> 
    		 
    		 <channel name ="SampleXmlChannel" messageType="xml"/> 
    		  
    		 <!-- A simple channel passing rawData --> 
    		 
    		 <channel name ="SampleRawDataChannel" messageType="rawData"/> 
    		  
    		 <!-- A simple channel passing a string --> 
    		 
    		 <channel name ="SampleStringChannel" messageType="string"/> 
             
    	 </channel>
    </channels>
  15. Uncomment the SampleXmlChannel entry in the above file to create an xml channel.
  16. To create the string channel, repeat the above steps but select SampleStringChannel instead of the SampleXmlChannel when you select the Channel Name.
  17. To create the RawData channel, repeat the above steps but select SampleRawDataChannel instead of the SampleXmlChannel when you select the Channel Name.
  18. Right-click RDBMS_ExampleWEb, select NewArrow symbolProcess.
  19. The New Process dialog box appears, enter a name in the Name field and click Finish.
  20. Double-click this new Process.java file.
  21. Double-click the Starting Event node.
  22. The following pop up is displayed as shown in Figure 3-8.

    Figure 3-8 Configuring Start Node


    Configuring Start Node

  23. Select the Subscribe to a Message Broker Channel and start via an event and close the dialog.
  24. Double-click on the node again.
  25. The Node Details dialog is displayed as shown in Figure 3-9.

    Figure 3-9 Node Details


    Node Details

  26. Select the SampleXmlChannel from the Channel Name drop-down list. If you have configured your own XMLChannel message broker, select it instead.
  27. If desired, you can click View Code in the bottom left-hand corner and enter the following System.out message:
  28. System.out.printIn(System.currentTimeMillis()+”-”+x0);
  29. Click the Receive Data tab and enter the variable details.
  30. Click Save.
  31. On the Package Explorer pane, select and right-click the Process.java file.
  32. Click Run As, and Run On Server.
  33. This deploys and runs the Process.java file on the server.

For the XML Channel, there is a type-safe way of retrieving the XML contents:

  1. Right-click on the Schemas folder in the Workshop project and click Import. Select the generated.XSD file from the Server domain directory. The .XSD is created in a folder with the same name as the channel rule definition.
  2. Workshop automatically compiles the .XSD file into Java classes
  3. For an event having the name testFirst, which publishes 2 columns of type CHAR and DATE, TableRowSet.xsd is the generated schema file. The contents of the subscription(..) method file outlined below illustrate how to use XmlObject using the generated classes.
  4. import com.bea.wli.rdbmsEG.testFirst.TableRowSetDocument;
    import com.bea.wli.rdbmsEG.testFirst.TableRowSetDocument.TableRowSet;
    import com.bea.wli.rdbmsEG.testFirst.TableRowSetDocument.TableRowSet.TableRow;
    ....
    public void subscription(com.bea.xml.XmlObject x0)
        {
            //#START: CODE GENERATED - PROTECTED SECTION - you can safely add code above this comment in this method. #//
            // input transform
            // parameter assignment
            //#END  : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
            final TableRowSetDocument doc = TableRowSetDocument.Factory.newInstance();
            doc.set(x0); 
            System.out.println("The document: " + doc);
            final TableRowSet rowSet = doc.getTableRowSet();
            final TableRow[] rows = rowSet.getTableRowArray();
            for(int i = 0; i < rows.length; i++)
            {
                System.out.println("---" + (i + 1) + "---");
                System.out.println("CHAR1: " + rows[i].getCHAR1());
                System.out.println("DATE1: " + rows[i].getDATE1());
            }
        }

For a RawData Channel, the code snippet below illustrates how it can be used to retrieve data published by the RDBMS Event Generator:

import com.bea.data.RawData;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import weblogic.jdbc.rowset.WLCachedRowSet;
….
    public void subscription(com.bea.data.RawData x0)
    {
        //#START: CODE GENERATED - PROTECTED SECTION - you can safely add code above this comment in this method. #//
        // input transform
        // parameter assignment
        //#END  : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
        try
        {
            ByteArrayInputStream arrayInputStream = new ByteArrayInputStream(rawData.byteValue());
            ObjectInputStream objectInputStream = new ObjectInputStream(arrayInputStream);
            WLCachedRowSet rowSet = (WLCachedRowSet) objectInputStream.readObject(); 
            System.out.println("-- Event --\r\n");
            while (rowSet.next())
            {
                Map map = rowSet.getCurrentRow(); 
                for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();)
                {
                    Object key = iterator.next();
                    System.out.println("  Column: " + key + ", Value: " + map.get(key));
                }
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

For more information on message broker channels, see Message Broker in Using The Oracle WebLogic Integration Administration Console.

The Message Broker module in the Oracle WebLogic Integration Administration Console allows you to monitor and manage all the Message Broker channels in your application.

Once you have created your data source and message broker channels, you can create RDBMS Event Generators and define channel rules for these generators in the Oracle WebLogic Integration Administration Console.

For information on creating RDBMS Event Generators and defining channel rules for these generators, see Event Generators in Using The Oracle WebLogic Integration Administration Console.


  Back to Top       Previous  Next