Contents

 

Overview

You will be creating an intelligent event processor quotes.iep that monitors a stream of stock quotes, and
updates a database table Latest2Quotes. Table Latest2Quotes will always hold the two latest stock quotes.
First you will create an IEP project quotesIEP. Next you will create an intelligent event processor
quotes.iep under project quotesIEP. Then you will create a deployment project quotesJBI to deploy the
intelligent event processor to the application server. Finally you will create a web services client, insert
stock quotes into the event stream, and observe the two latest stock quotes in table Latest2Quotes.

Software Needed for this Tutorial

Before you begin, you must install the following software on your computer:

 

Configuring the Tutorial Environment

Before you can deploy your application, the Sun Java System Application Server and JBI runtime must be configured correctly and running.

To configure the tutorial environment:

  1. Click the Runtime tab to open the Runtime window.
  2. In the Runtime window, expand the Servers node.
  3. If the Servers node already contains a Sun Java System Application Server 9 node, then go to step 5.
  4. If the Servers node does not contain a Sun Java System Application Server 9 node, then do the following to add an application server:
    1. Right-click the Servers node and choose Add Server from the pop-up menu.
      The Add Server Instance dialog box opens.
    2. In the Choose Server page, from the Server drop-down list, select Sun Java System Application Server.
    3. (Optional) In the Name field, accept the default value or type the name you want to use to identify the server in the IDE.
    4. Click Next.
      The Platform Location Folder page opens.
    5. In the Platform Location field, use the Browse button to navigate to and select the Application Server installation location.
      If you accepted the default values during the installation, the location is C:\Sun\Appserver .
    6. Select the Register Local Default Domain radio button.
    7. Click Next.
    8. Supply the user name and password for the domain's administrator.
      If you accepted the default values during the installation, the user name is admin and the password is adminadmin .
    9. Click Finish.
  5. In the Runtime window, right-click the Sun Java System Application Server 9 node and choose Start.
    If the Start option is not available, the server is already running and you can skip the next step.
  6. Wait until the following message appears in the Output window:
    Application server startup complete.
    When the server is running, the IDE displays a green arrow badge on the Sun Java System Application Server 9 node.
  7. Expand Sun Java System Application Server 9 > JBI > Service Engines.
  8. Rightclick com.sun.iepse-1.0-2-1.0-2. Notice that Start option is gray.

Creating the IEP Project

In this section, you create a IEP Module project called quotesIEP .

To create the quotesIEP

  1. Click menu File and select New Project
  2. Select Service Oriented Architecture from Categories, select Intelligent Event Processing Module from Projects, and click Next button.
  3. Input “quotesIEP” for entry: Project Name, and click Finish.
  4. Right-mouse-click on folder quotesIEP\Source Packages, and select New\Intelligent Event Processor.
  5. Input “quotes” for entry: File Name,and click Finish.
    The IDE does the following:

.To add Operators from the IEP Operator Palette

  1. Expand Input from the IEP palette.
  2. Drag “Stream Input” operator from Input palette onto the design canvas.
  3. From the Palette, expand Stream Converter and drag “Tuple Based Window” operator onto the design canvas.
  4. From the Palette, expand Output and Drag “Table Output” operator from onto the design canvas
  5. Connect the three operators by dragging lines between their ports
  6. To configure operator StreamInput0. In the design view, double-click on operator StreamInput0.
    The “StreamInput0 – property editor” window pops up.
  7. Under Attributes, for Attribute Name column input 'Symbol'. VARCHAR for Data Type, and 10 for Size.
  8. Then click the Add Attribute button to add another Attribute.
  9. Input 'Price' for column Attribute Name, Double for Data Type.
  10. Click Ok.
  11. To configure operator TupleBasedWindow0 so that it will only keep the two latest quotes,
    double-click operator TupleBasedWindow0.
    You will see a pop-up window “TupleBasedWindow0 opens.
  12. In the property editor input 2 for Size property and click Ok.
  13. Double-click operator TableOutput0 on the design canvas. You will see a pop-up window
    “TableOutput0 – property editor”. Check property Is Global, and change the value of property Global Id to
    “Latest2Quotes”.
  14. Click Ok and Save.

Creating and Deploying the Composite Application

To create the Composite Application project and add the JBI module:

  1. From the menu select New Project.
  2. Select Service Oriented Architecture from Categories, select Composite Application from Projects and click Next.
  3. Input 'quotesCompositeApp' for Project Name and click Finish.
  4. Right-click on folder quotesCompositeApp, and select Add JBI Module.
  5. Navigate to the directory under which you created your quotesCompositeApp,select folder quotesCompositeApp, and click button Add Project JAR Files.

To deploy the Composite Application:

  1. Right-click on folder quotesCompositeApp, and select Deploy Project.
    If the BUILD SUCCESSFUL message appears in the Output window, then the deployment has succeeded.

Testing the quotesCommpositeApp

To Test the quotesCompositeApp Application
You will create a connection to the Java DB database server from within your NetBeans IDE so that you
can view the content of its tables. You will use a Java Project to insert stock quotes into the event stream, and observe the two latest stock quotes in table
Latest2Quotes.

  1. In the “Runtime” window of NetBeans, rightclick Databases and select New Connection.
    The New Database Connection window opens.
  2. Input “jdbc:derby://localhost/architect” for Database URL, “architect” for User Name, and “architect” for Password.
  3. Check “Remember password during this session”, and click OK.
    Notice the folder “jdbc:derby://localhost//architect[architect on ARCHITECT]” under folder
    Databases. A connection to the Java DB database server from within NetBeans IDE is created.
  4. Expand the jdbc:derby://localhost/architect[architect on ARCHITECT] and Tables
  5. Rightclick LAST2QUOTES, and select View Data
    Notice the table is empty
  6. Next you will insert stock quotes into the event stream, and observe the two latest stock quotes in table
    Latest2Quotes. Run input.bat in directory chapter1 as shown below .

To Run the Java Project

In this section, you open the Java application provided with this tutorial to send event stream to test the IEP project.

  1. Create a directory on your file system named IEPTut and unzip the quotesSender.zip file into the directory.
  2. From the main menu, choose File > Open Project.
  3. Browse to the IEPTut directory that you just created and select the quotesSender project.
  4. Leave the checkbox Open as Main Project selected and click Open Project Folder.
    A progress dialog box appears and then a node for the JavaApp project appears in the Projects window.
  5. Rightclick quotesSender project and select Run Project.
    This will send a soap message to the event processor quotes.iep.
  6. In the Output window make sure the quotesSender(run) tab is selected.
  7. In the Output window, Input field, type 'y' and press enter.
  8. Click the “Run SQL” button (green arrow) in window and you will see the latest quote in table LATEST2QUOTES.
  9. Repeat steps 6-8 to send another quote from the JavaApp Project.
    Notice the latest 2 quotes in table LATEST2QUOTES are changed. Note that quote (ADBE, 63) is deleted from the table. This is
    because the TupleBasedWindow operator in quotes.iep is configured to only keep the latest 2 events.