Skip Headers
Oracle® Fusion Middleware Developer's Guide for Oracle Event Processing
11g Release 1 (11.1.1.7) for Eclipse

Part Number E14301-09
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

2 Oracle Event Processing Samples

This chapter introduces sample code provided with Oracle Event Processing, describing how to set up and use code ranging from simple "Hello World" to applications of Oracle Continuous Query Language (Oracle CQL), as well as for spatial and industry-focused scenarios.

This chapter includes the following sections:

2.1 Overview of the Samples Provided in the Distribution Kit

Oracle Event Processing includes the following samples:

These samples are provided in two forms, as follows:

The samples use Ant as their development tool; for details about Ant and installing it on your computer, see http://ant.apache.org/.

2.1.1 Ready-to-Run Samples

Out-of-the-box sample domains pre-configured to deploy an assembled application; each sample has its own domain for simplicity. Each domain is a standalone server domain; the server files are located in the defaultserver subdirectory of the domain directory. To deploy the application you simply start the default server in the domain.

2.1.2 Sample Source

The Java and configuration XML source for each sample is provided in a separate source directory that describes a sample development environment.

2.2 Installing the Default ocep_domain and Samples

To install all Oracle Event Processing components including the default ocep_domain domain (with default passwords) and the samples, you must chose the Custom option to also install the samples. The Typical option does not include the default ocep_domain and samples.

If you previously installed Oracle Event Processing using the Typical option, and you now want to also install the samples, re-run the Oracle Event Processing installation process and specify the same Oracle Event Processing home directory; a later step in the installation process allows you to then install just the samples.

2.3 Using Oracle Event Processing Visualizer With the Samples

The Oracle Event Processing Visualizer is a Web 2.0 application that consumes data from Oracle Event Processing, displays it in a useful and intuitive way to system administrators and operators, and, for specified tasks, accepts data that is then passed back to Oracle Event Processing so as to change it configuration.

Visualizer is itself an Oracle Event Processing application and is automatically deployed in each server instance. To use it with the samples, be sure you have started the server (instructions provided for each sample below) and then invoke the following URL in your browser:

http://host:9002/wlevs

where host refers to the name of the computer hosting Oracle Event Processing; if it is the same as the computer on which the browser is running you can use localhost.

Security is disabled for the HelloWorld application, so you can click Logon at the login screen without entering a username and password. For the FX and signal generation samples, however, security is enabled, so use the following to logon:

User Id: wlevs
   Password: wlevs

For more information about Oracle Event Processing Visualizer, see Oracle Fusion Middleware Visualizer User's Guide for Oracle Event Processing.

2.4 Increasing the Performance of the Samples

To increase the throughput and latency when running the samples, and Oracle Event Processing applications in general, Oracle recommends the following:

2.5 HelloWorld Example

The first example that shows how to create an Oracle Event Processing application is the ubiquitous HelloWorld.

Figure 2-1 shows the HelloWorld example Event Processing Network (EPN). The EPN contains the components that make up the application and how they fit together.

Figure 2-1 The HelloWorld Example Event Processing Network

Description of Figure 2-1 follows
Description of "Figure 2-1 The HelloWorld Example Event Processing Network"

The example includes the following components:

2.5.1 Running the HelloWorld Example from the helloworld Domain

The HelloWorld application is pre-deployed to the helloworld domain. To run the application, you simply start an instance of Oracle Event Processing server.

To run the HelloWorld example from the helloworld domain:

  1. Open a command window and change to the default server directory of the helloworld domain directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\domains\helloworld_domain\defaultserver, where MIDDLEWARE_HOME refers to the Middleware home directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

    prompt> cd d:\Oracle\Middleware\ocep_11.1\samples\domains\helloworld_domain\defaultserver
    
  2. Ensure the environment is set correctly in the server startup script.

    For more information, see Chapter 3, "Getting Started with Developing Oracle Event Processing Applications"

  3. Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:

    1. On Windows:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.cmd -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.cmd
        
    2. On UNIX:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.sh -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.sh
        

    After server status messages scroll by, you should see the following message printed to the output about every second:

    Message: HelloWorld - the current time is: 3:56:57 PM
    

    This message indicates that the HelloWorld example is running correctly.

2.5.2 Building and Deploying the HelloWorld Example from the Source Directory

The HelloWorld sample source directory contains the Java source, along with other required resources such as configuration XML files, that make up the HelloWorld application. The build.xml Ant file contains targets to build and deploy the application to the helloworld domain.

For more information, see Section 2.5.3, "Description of the Ant Targets to Build Hello World".

To build and deploy the HelloWorld example from the source directory:

  1. If the helloworld Oracle Event Processing instance is not already running, follow the procedure in Section 2.5.1, "Running the HelloWorld Example from the helloworld Domain" to start the server.

    You must have a running server to successfully deploy the rebuilt application.

  2. Open a new command window and change to the HelloWorld source directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\source\applications\helloworld where MIDDLEWARE_HOME is the Middleware home directory you specified when you installed Oracle Event Processing.

    For example:

    prompt> cd d:\Oracle\Middleware\ocep_11.1\samples\source\applications\helloworld
    
  3. Set your development environment as described in Section 3.2, "Setting Your Development Environment."

  4. Execute the all Ant target to compile and create the application JAR file:

    prompt> ant all
    
  5. Execute the deploy Ant target to deploy the application JAR file to Oracle Event Processing:

    prompt> ant -Daction=update deploy
    

    Caution:

    This target overwrites the existing helloworld application JAR file in the domain directory.

You should see the following message printed to the output about every second:

Message: HelloWorld - the current time is: 3:56:57 PM

This message indicates that the HelloWorld example has been redeployed and is running correctly.

2.5.3 Description of the Ant Targets to Build Hello World

The build.xml file, located in the top level of the HelloWorld source directory, contains the following targets to build and deploy the application:

  • clean—This target removes the dist and output working directories under the current directory.

  • all—This target cleans, compiles, and JARs up the application into a file called com.bea.wlevs.example.helloworld_11.1.1.4_0.jar, and places the generated JAR file into a dist directory below the current directory.

  • deploy—This target deploys the JAR file to Oracle Event Processing using the Deployer utility.

    For more information, see "Deployer Command-Line Reference" in the Oracle Fusion Middleware Administrator's Guide for Oracle Event Processing.

2.5.4 Implementation of the HelloWorld Example

The implementation of the HelloWorld example generally follows Section 3.1, "Creating an Oracle Event Processing Application".

Refer to that section for a task-oriented procedure that describes the typical development process.

The HelloWorld example, because it is relatively simple, does not use all the components and configuration files described in the general procedure for creating an Oracle Event Processing application.

All the example files are located relative to the MIDDLEWARE_HOME\ocep_11.1\samples\source\applications\helloworld directory, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing c:\Oracle\Middleware. Oracle recommends that you use this example directory setup in your own environment, although it is obviously not required.

The files used by the HelloWorld example include:

  • An EPN assembly file that describes each component in the application and how all the components are connected together. The EPN assembly file extends the standard Spring context file. The file also registers the event types used in the application. You are required to include this XML file in your Oracle Event Processing application.

    In the example, the file is called com.bea.wlevs.example.helloworld-context.xml and is located in the META-INF/spring directory.

  • Java source file for the helloworldAdapter component.

    In the example, the file is called HelloWorldAdapter.java and is located in the src/com/bea/wlevs/adapter/example/helloworld directory.

    For a detailed description of this file and how to program the adapter Java files in general, see Chapter 15, "Integrating an External Component Using a Custom Adapter".

  • Java source file that describes the HelloWorldEvent event type.

    In the example, the file is called HelloWorldEvent.java and is located in the src/com/bea/wlevs/event/example/helloworld directory.

    For a detailed description of this file, as well as general information about programming event types, see Chapter 9, "Defining and Using Event Types".

  • An XML file that configures the helloworldProcessor and helloworldOutputChannel components. An important part of this file is the set of EPL rules that select the set of events that the HelloWorld application processes. You are required to include a processor configuration file in your Oracle Event Processing application, although the adapter and channel configuration is optional.

    In the example, the file is called config.xml and is located in the META-INF/wlevs directory.

  • A Java file that implements the helloworldBean component of the application, a POJO that contains the business logic.

    In the example, the file is called HelloWorldBean.java and is located in the src/com/bea/wlevs/example/helloworld directory.

    For a detailed description of this file, as well as general information about programming event sinks, see Chapter 16, "Handling Events with Java".

  • A MANIFEST.MF file that describes the contents of the OSGi bundle that will be deployed to Oracle Event Processing.

    In the example, the MANIFEST.MF file is located in the META-INF directory.

    For more information about creating this file, as well as a description of creating the OSGi bundle that you deploy to Oracle Event Processing, see Section 23.1, "Overview of Application Assembly and Deployment".

The HelloWorld example uses a build.xml Ant file to compile, assemble, and deploy the OSGi bundle; see Section 2.5.2, "Building and Deploying the HelloWorld Example from the Source Directory" for a description of this build.xml file if you also use Ant in your development environment.

2.6 Oracle Continuous Query Language (Oracle CQL) Example

The Oracle CQL example shows how to use the Oracle Event Processing Visualizer Query Wizard to construct various types of Oracle CQL queries.

Figure 2-2 shows the CQL example Event Processing Network (EPN). The EPN contains the components that make up the application and how they fit together.

Figure 2-2 The CQL Example Event Processing Network

Description of Figure 2-2 follows
Description of "Figure 2-2 The CQL Example Event Processing Network"

The application contains three separate event paths in its EPN:

Note:

For more information about the various components in the EPN, see the other samples in this book.

2.6.1 Running the CQL Example

For optimal demonstration purposes, Oracle recommends that you run this example on a powerful computer, such as one with multiple CPUs or a 3 GHz dual-core Intel, with a minimum of 2 GB of RAM.

The CQL application is pre-deployed to the cql_domain domain. To run the application, you simply start an instance of Oracle Event Processing server.

To run the CQL example:

  1. Open a command window and change to the default server directory of the CQL domain directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\domains\cql_domain\defaultserver, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

    prompt> cd d:\Oracle\Middleware\ocep_11.1\samples\domains\cql_domain\defaultserver
    
  2. Set your development environment, as described in Chapter 3, "Setting Your Development Environment"

  3. Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:

    1. On Windows:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.cmd -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.cmd
        
    2. On UNIX:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.sh -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.sh
        

    The CQL application is now ready to receive data from the data feeds.

  4. To simulate the data feed for the missing event query, open a new command window and set your environment as described in Chapter 3, "Getting Started with Developing Oracle Event Processing Applications"

  5. Change to the MIDDLEWARE_HOME\ocep_11.1\utils\load-generator directory, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

  6. Run the load generator using the orderData.prop properties file:

    1. On Windows:

      prompt> runloadgen.cmd orderData.prop
      
    2. On UNIX:

      prompt> runloadgen.sh orderData.prop
      
  7. To simulate the data feed for the moving average query, open a new command window and set your environment as described in Chapter 3, "Getting Started with Developing Oracle Event Processing Applications"

  8. Change to the MIDDLEWARE_HOME\ocep_11.1\utils\load-generator directory, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

  9. Run the load generator using the stockData.prop properties file:

    1. On Windows:

      prompt> runloadgen.cmd stockData.prop
      
    2. On UNIX:

      prompt> runloadgen.sh stockData.prop
      
  10. To simulate the data feed for the cache query, you only need to run the example.

    The load data is generated by Adaptor.java and the cache data is generated by Loader.java. You can verify that data is flowing through by turning on statistics in the Oracle Event Processing Visualizer Query Plan.

2.6.2 Building and Deploying the CQL Example

The CQL sample source directory contains the Java source, along with other required resources such as configuration XML files, that make up the CQL application. The build.xml Ant file contains targets to build and deploy the application to the cql_domain domain, as described in Section 2.5.3, "Description of the Ant Targets to Build Hello World."

To build and deploy the CQL example from the source directory:

  1. If the CQL Oracle Event Processing instance is not already running, follow the procedure in Section 2.6.1, "Running the CQL Example" to start the server.

    You must have a running server to successfully deploy the rebuilt application.

  2. Open a new command window and change to the CQL source directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\source\applications\cql, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

    prompt> cd d:\Oracle\Middleware\ocep_11.1\samples\source\applications\cql
    
  3. Set your development environment, as described in Section 3.2, "Setting Your Development Environment"

  4. Execute the all Ant target to compile and create the application JAR file:

    prompt> ant all
    
  5. Execute the deploy Ant target to deploy the application JAR file to Oracle Event Processing:

    prompt> ant -Dusername=wlevs -Dpassword=wlevs -Daction=update deploy
    

    Caution:

    This target overwrites the existing CQL application JAR file in the domain directory.

  6. If the load generators required by the CQL application are not running, start them as described in Section 2.6.1, "Running the CQL Example."

2.6.3 Description of the Ant Targets to Build the CQL Example

The build.xml file, located in the top-level directory of the CQL source, contains the following targets to build and deploy the application:

  • clean—This target removes the dist and output working directories under the current directory.

  • all—This target cleans, compiles, and jars up the application into a file called com.bea.wlevs.example.cql_11.1.1.4_0.jar, and places the generated JAR file into a dist directory below the current directory.

  • deploy—This target deploys the JAR file to Oracle Event Processing using the Deployer utility.

    For more information, see "Deployer Command-Line Reference" in the Oracle Fusion Middleware Administrator's Guide for Oracle Event Processing.

2.6.4 Implementation of the CQL Example

This section describes how to create the queries that the CQL example uses, including:

2.6.4.1 Creating the Missing Event Query

This section describes how to use the Oracle Event Processing Visualizer Query Wizard to create the Oracle CQL pattern matching query that the cqlProc processor executes to detect missing events.

Consider a customer order workflow in which you have customer order workflow events flowing into the Oracle Event Processing system.

In a valid scenario, you see events in the order that Table 2-1 lists:

Table 2-1 Valid Order Workflow

Event Type Description

C

Customer order

A

Approval

S

Shipment


However, it is an error if an order is shipped without an approval event as Table 2-2 lists:

Table 2-2 Invalid Order Workflow

Event Type Description

C

Customer order

S

Shipment


You will create and test a query that detects the missing approval event and generates an alert event:

To create the missing event query:

  1. If the CQL Oracle Event Processing instance is not already running, follow the procedure in Section 2.6.1, "Running the CQL Example" to start the server.

    You must have a running server to use the Oracle Event Processing Visualizer.

  2. Invoke the following URL in your browser:

    http://host:port/wlevs
    

    where host refers to the name of the computer on which Oracle Event Processing is running and port refers to the Jetty NetIO port configured for the server (default value 9002).

    The Logon screen appears as Figure 2-3 shows.

    Figure 2-3 Oracle Event Processing Visualizer Logon Screen

    Description of Figure 2-3 follows
    Description of "Figure 2-3 Oracle Event Processing Visualizer Logon Screen"

  3. In the Logon screen, enter the User Id wlevs and Password wlevs, and click Log In.

    The Oracle Event Processing Visualizer dashboard appears as Figure 2-4 shows.

    Figure 2-4 Oracle Event Processing Visualizer Dashboard

    Description of Figure 2-4 follows
    Description of "Figure 2-4 Oracle Event Processing Visualizer Dashboard"

    For more information about the Oracle Event Processing Visualizer user interface, see "Understanding the Oracle Event Processing Visualizer User Interface" in the Oracle Fusion Middleware Visualizer User's Guide for Oracle Event Processing.

  4. In the right-hand pane, expand WLEventServerDomain > NonClusteredServer > Applications.

  5. Select the cql node.

    The CQL application screen appears as Figure 2-5 shows.

    Figure 2-5 CQL Application Screen: General Tab

    Description of Figure 2-5 follows
    Description of "Figure 2-5 CQL Application Screen: General Tab"

  6. Select the Event Processing Network tab.

    The Event Processing Network screen appears as Figure 2-6 shows.

    Figure 2-6 CQL Application: Event Processing Network Tab

    Description of Figure 2-6 follows
    Description of "Figure 2-6 CQL Application: Event Processing Network Tab"

  7. Double-click the orderProcessor Oracle CQL processor icon.

    The Oracle CQL processor screen appears as Figure 2-7 shows.

    Figure 2-7 Oracle CQL Processor: General Tab

    Description of Figure 2-7 follows
    Description of "Figure 2-7 Oracle CQL Processor: General Tab"

  8. Select the Query Wizard tab.

    The Query Wizard screen appears as Figure 2-8 shows.

    Figure 2-8 Oracle CQL Processor: Query Wizard Tab

    Description of Figure 2-8 follows
    Description of "Figure 2-8 Oracle CQL Processor: Query Wizard Tab"

    You can use the Oracle CQL Query Wizard to construct an Oracle CQL query from a template or from individual Oracle CQL constructs.

    In this procedure, you are going to create an Oracle CQL query from a template.

    For more information, see "Creating a Rule in an Oracle CQL Processor Using the Query Wizard" in the Oracle Fusion Middleware Visualizer User's Guide for Oracle Event Processing.

  9. Click the Templates tab.

    The Templates tab appears as Figure 2-9 shows.

  10. Click and drag the Pattern Match Template from the Templates palette and drop it anywhere in the Query Wizard canvas as shown in Figure 2-9.

  11. Double-click the SSource icon.

    The SSource configuration screen appears as Figure 2-10 shows.

    Figure 2-10 SSource Configuration Dialog

    Description of Figure 2-10 follows
    Description of "Figure 2-10 SSource Configuration Dialog"

    The source of your query will be the orderChannel stream.

  12. Configure the SSource as follows:

    • Select Stream as the Type.

    • Select orderChannel from the Select a source pull-down menu.

  13. Click Save.

  14. Click Save Query.

  15. Double-click the Pattern icon.

    The Pattern configuration screen appears as Figure 2-11 shows.

    Figure 2-11 Pattern Configuration Dialog: Pattern Tab

    Description of Figure 2-11 follows
    Description of "Figure 2-11 Pattern Configuration Dialog: Pattern Tab"

    Using the Pattern tab, you will define the pattern expression that matches when missed events occur. The expression is made in terms of named conditions that you will specify on the Define tab in a later step.

  16. Enter the following expression in the Pattern Expression field:

    CustOrder NoApproval*? Shipment 
    

    This pattern uses the Oracle CQL pattern quantifiers that Table 2-3 lists. Use the pattern quantifiers to specify the allowed range of pattern matches. The one-character pattern quantifiers are maximal or "greedy"; they will attempt to match the biggest quantity first. The two-character pattern quantifiers are minimal or "reluctant"; they will attempt to match the smallest quantity first.

    Table 2-3 MATCH_RECOGNIZE Pattern Quantifiers

    Maximal Minimal Description

    *

    *?

    0 or more times

    +

    +?

    1 or more times.

    ?

    ??

    0 or 1 time.


    For more information, see:

  17. Select orderid from the Partition By pull-down menu and click the Plus Sign button to add this property to the PARTITION BY clause.

    This ensures that Oracle Event Processing evaluates the missing event query on each order.

  18. Enter Orders in the Alias field.

    This assigns an alias (Orders) for the pattern to simplify its use later in the query.

  19. Click the Define tab.

    The Define tab appears as Figure 2-12 shows.

    Figure 2-12 Pattern Configuration Dialog: Define Tab

    Description of Figure 2-12 follows
    Description of "Figure 2-12 Pattern Configuration Dialog: Define Tab"

    You will now define each of the conditions named in the pattern clause as Table 2-4 lists:

    Table 2-4 Condition Definitions

    Condition Name Definition

    CustOrder

    orderChannel.eventType = 'C'

    NoApproval

    NOT(orderChannel.eventType = 'A')

    Shipment

    orderChannel.eventType = 'C'


  20. Enter CustOrder in the Object Name field.

  21. Click the Expression Builder button and configure the Expression Builder as follows (see Figure 2-13):

    • In the Variables list, double-click eventType.

    • In the Operands list, double-click =.

    • After the = operand, enter the value 'C'.

    Figure 2-13 Expression Builder: CustOrder

    Description of Figure 2-13 follows
    Description of "Figure 2-13 Expression Builder: CustOrder"

  22. Click Save.

  23. Click the Plus Sign button.

    The condition definition is added to the Object List as Figure 2-14 shows.

    Figure 2-14 Pattern Configuration Dialog: Define Tab With CustOrder Condition

    Description of Figure 2-14 follows
    Description of "Figure 2-14 Pattern Configuration Dialog: Define Tab With CustOrder Condition"

  24. Enter NoApproval in the Object Name field.

  25. Click the Expression Builder button and configure the Expression Builder as follows (see Figure 2-15):

    • In the Variables list, double-click eventType.

    • In the Operands list, double-click =.

    • After the = operand, enter the value 'A'.

    • Place parenthesis around the expression.

    • Place the insertion bar at the beginning of the expression, outside the open parenthesis.

    • In the Operands list, double-click NOT.

    Figure 2-15 Expression Builder: NoApproval

    Description of Figure 2-15 follows
    Description of "Figure 2-15 Expression Builder: NoApproval"

  26. Click Save.

  27. Click the Plus Sign button.

    The condition definition is added to the Object List.

  28. Enter Shipment in the Object Name field.

  29. Click the Expression Builder button and configure the Expression Builder as follows (see Figure 2-16):

    • In the Variables list, double-click eventType.

    • In the Operands list, double-click =.

    • After the = operand, enter the value 'S'.

    Figure 2-16 Expression Builder: Shipment

    Description of Figure 2-16 follows
    Description of "Figure 2-16 Expression Builder: Shipment"

  30. Click Save.

  31. Click the Plus Sign button.

    The Define tab appears as Figure 2-17 shows.

    Figure 2-17 Pattern Configuration Dialog: Define Tab Complete

    Description of Figure 2-17 follows
    Description of "Figure 2-17 Pattern Configuration Dialog: Define Tab Complete"

  32. Click the Measure tab.

    The Measure tab appears as Figure 2-18 shows.

    Use the Measure tab to define expressions in a MATCH_RECOGNIZE condition and to bind stream elements that match conditions in the DEFINE clause to arguments that you can include in the select statement of a query.

    Use the Measure tab to specify the following:

    • CustOrder.orderid AS orderid

    • CustOrder.amount AS amount

    For more information, see:

  33. Enter orderid in the Object Name field.

  34. Click the Expression Builder button and configure the Expression Builder as follows (see Figure 2-19):

    • In the Variables list, double-click CustOrder.orderid.

    Figure 2-19 Expression Builder: orderid

    Description of Figure 2-19 follows
    Description of "Figure 2-19 Expression Builder: orderid"

  35. Click Save.

  36. Click the Plus Sign button.

  37. Enter amount in the Object Name field.

  38. Click the Expression Builder button and configure the Expression Builder as follows (see Figure 2-20):

    • In the Variables list, double-click CustOrder.amount.

    Figure 2-20 Expression Builder: amount

    Description of Figure 2-20 follows
    Description of "Figure 2-20 Expression Builder: amount"

  39. Click Save.

  40. Click the Plus Sign button.

    The Measure tab appears as Figure 2-21 shows.

    Figure 2-21 Measure Tab: Complete

    Description of Figure 2-21 follows
    Description of "Figure 2-21 Measure Tab: Complete"

  41. Click Save.

  42. Double-click the Select icon.

    The Select configuration screen appears as Figure 2-22 shows.

    Figure 2-22 Select Configuration Dialog: Project Tab

    Description of Figure 2-22 follows
    Description of "Figure 2-22 Select Configuration Dialog: Project Tab"

  43. Configure the Project tab as follows:

    • Select AlertEvent from the Select or Input Event Type pull-down menu.

    • Select Orders from the Select a source pull-down menu.

  44. Double-click orderid in the Properties list and select orderid from the Select or Input Alias pull-down menu.

  45. Click the Plus Sign button to add the property to the Generated CQL Statement.

  46. Double-click amount in the Properties list and select amount from the Select or Input Alias pull-down menu.

  47. Click the Plus Sign button to add the property to the Generated CQL Statement.

  48. Click in the Project Expression field and enter the value "Error - Missing Approval" and select alertType from the Select or Input Alias pull-down menu.

  49. Click the Plus Sign button to add the property to the Generated CQL Statement.

    The Project tab appears as Figure 2-23 shows.

    Figure 2-23 Select Configuration Dialog: Project Tab Complete

    Description of Figure 2-23 follows
    Description of "Figure 2-23 Select Configuration Dialog: Project Tab Complete"

  50. Click Save.

  51. Click Save Query.

  52. Double-click the Output icon.

    The Output configuration screen appears as Figure 2-24 shows.

    Figure 2-24 Output Configuration Dialog

    Description of Figure 2-24 follows
    Description of "Figure 2-24 Output Configuration Dialog"

  53. Configure the Output as follows:

    • Select Query.

    • Enter Tracking as the Query Name.

  54. Click Inject Rule.

    The Inject Rule Confirmation dialog appears as Figure 2-25 shows.

    Figure 2-25 Inject Rule Confirmation Dialog

    Description of Figure 2-25 follows
    Description of "Figure 2-25 Inject Rule Confirmation Dialog"

  55. Click OK.

    The Query Wizard adds the rule to the cqlProc processor.

  56. Click Save.

  57. Click on the CQL Rules tab.

    The CQL Rules tab appears as Figure 2-26 shows.

  58. Click on the Query radio button.

    Confirm that your Tracking query is present.

    Figure 2-26 CQL Rules Tab With Tracking Query

    Description of Figure 2-26 follows
    Description of "Figure 2-26 CQL Rules Tab With Tracking Query"

To test the missing event query:

  1. To simulate the data feed for the missing event query, open a new command window and set your environment as described in Chapter 3, "Getting Started with Developing Oracle Event Processing Applications"

  2. Change to the MIDDLEWARE_HOME\ocep_11.1\utils\load-generator directory, where MIDDLEWARE_HOME refers to the Middleware directory created when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

  3. Run the load generator using the orderData.prop properties file:

    1. On Windows:

      prompt> runloadgen.cmd orderData.prop
      
    2. On UNIX:

      prompt> runloadgen.sh orderData.prop
      
  4. In the Oracle Event Processing Visualizer, click the ViewStream button in the top pane.

    The Stream Visualizer screen appears as Figure 2-27 shows.

    Figure 2-27 Stream Visualizer: Showing Missing Events

    Description of Figure 2-27 follows
    Description of "Figure 2-27 Stream Visualizer: Showing Missing Events"

  5. Click Initialize Client.

  6. Click the Subscribe tab.

  7. Select the orderalert radio button.

  8. Click Subscribe.

    As missing events are detected, the Oracle Event Processing updates the Received Messages area showing the AlertEvents generated.

2.6.4.2 Creating the Moving Average Query

This section describes how to use the Oracle Event Processing Visualizer Query Wizard to create the Oracle CQL moving average query that the stockProc processor executes.

You do this in two steps:

To create a view source for the moving average query:

  1. If the CQL Oracle Event Processing instance is not already running, follow the procedure in Section 2.6.1, "Running the CQL Example" to start the server.

    You must have a running server to use the Oracle Event Processing Visualizer.

  2. Invoke the following URL in your browser:

    http://host:port/wlevs
    

    where host refers to the name of the computer on which Oracle Event Processing is running and port refers to the Jetty NetIO port configured for the server (default value 9002).

    The Logon screen appears as Figure 2-28 shows.

    Figure 2-28 Oracle Event Processing Visualizer Logon Screen

    Description of Figure 2-28 follows
    Description of "Figure 2-28 Oracle Event Processing Visualizer Logon Screen"

  3. In the Logon screen, enter the User Id wlevs and Password wlevs, and click Log In.

    The Oracle Event Processing Visualizer dashboard appears as Figure 2-29 shows.

    Figure 2-29 Oracle Event Processing Visualizer Dashboard

    Description of Figure 2-29 follows
    Description of "Figure 2-29 Oracle Event Processing Visualizer Dashboard"

    For more information about the Oracle Event Processing Visualizer user interface, see "Understanding the Oracle Event Processing Visualizer User Interface" in the Oracle Fusion Middleware Visualizer User's Guide for Oracle Event Processing.

  4. In the right-hand pane, expand WLEventServerDomain > NonClusteredServer > Applications.

  5. Select the cql node.

    The CQL application screen appears as Figure 2-30 shows.

    Figure 2-30 CQL Application Screen: General Tab

    Description of Figure 2-30 follows
    Description of "Figure 2-30 CQL Application Screen: General Tab"

  6. Select the Event Processing Network tab.

    The Event Processing Network screen appears as Figure 2-31 shows.

    Figure 2-31 CQL Application: Event Processing Network Tab

    Description of Figure 2-31 follows
    Description of "Figure 2-31 CQL Application: Event Processing Network Tab"

  7. Double-click the stockProcessor Oracle CQL processor icon.

    The Oracle CQL processor screen appears as Figure 2-32 shows.

    Figure 2-32 Oracle CQL Processor: General Tab

    Description of Figure 2-32 follows
    Description of "Figure 2-32 Oracle CQL Processor: General Tab"

  8. Select the Query Wizard tab.

    The Query Wizard screen appears as Figure 2-33 shows.

    Figure 2-33 Oracle CQL Processor: Query Wizard Tab

    Description of Figure 2-33 follows
    Description of "Figure 2-33 Oracle CQL Processor: Query Wizard Tab"

    You can use the Oracle CQL Query Wizard to construct an Oracle CQL query from a template or from individual Oracle CQL constructs.

    In this procedure, you are going to create an Oracle CQL view and query from individual Oracle CQL constructs.

    For more information, see "Creating a Rule in an Oracle CQL Processor Using the Query Wizard" in the Oracle Fusion Middleware Visualizer User's Guide for Oracle Event Processing.

  9. Click and drag an SSource icon (Stream Source) from the CQL Constructs palette and drop it anywhere in the Query Wizard canvas as Figure 2-34 shows.

    Figure 2-34 Query Wizard: SSource

    Description of Figure 2-34 follows
    Description of "Figure 2-34 Query Wizard: SSource"

  10. Double-click the SSource icon.

    The SSource configuration screen appears.

    The source of your view will be the stockChannel stream. You want to select stock events from this stream where the volume is greater than 1000. This will be the source for your moving average query.

  11. Configure the SSource as follows (as shown in Figure 2-35):

    • Select Stream as the Type.

      The source of your view is the stockChannel stream.

    • Select stockChannel from the Select a source pull-down menu.

    • Enter the alias StockVolGt1000 in the AS field.

    Figure 2-35 SSource Configuration Dialog

    Description of Figure 2-35 follows
    Description of "Figure 2-35 SSource Configuration Dialog"

  12. Click Save.

  13. Click Save Query.

  14. When prompted, enter StockVolGt1000 in the Query Id field.

  15. Click Save.

    Next, you will add an Oracle CQL filter.

  16. Click and drag a Filter icon from the CQL Constructs palette and drop it anywhere in the Query Wizard canvas as Figure 2-36 shows.

    Figure 2-36 Query Wizard: Filter

    Description of Figure 2-36 follows
    Description of "Figure 2-36 Query Wizard: Filter"

  17. Click on the SSource icon and drag to the Window icon to connect the Oracle CQL constructs as Figure 2-37 shows.

    Figure 2-37 Connecting the SSource and Filter Icons

    Description of Figure 2-37 follows
    Description of "Figure 2-37 Connecting the SSource and Filter Icons"

  18. Double-click the Filter icon.

    The Filter configuration screen appears as Figure 2-38 shows.

    Figure 2-38 Filter Configuration Dialog

    Description of Figure 2-38 follows
    Description of "Figure 2-38 Filter Configuration Dialog"

  19. Click the Expression Builder button.

    The Expression Builder dialog appears.

  20. Configure the Expression Builder as follows (as shown in Figure 2-39):

    • Select StockVolGt100 from the Select an Event Type pull-down menu to define the variables you can use in this expression.

    • Double-click the volume variable to add it to the Expression Builder field.

    • Double-click > in the Operands list to add it to the Expression Builder field.

    • Enter the value 1000 after the > operand.

      Figure 2-39 Filter Expression Builder

      Description of Figure 2-39 follows
      Description of "Figure 2-39 Filter Expression Builder"

  21. Click Save.

  22. Click Add Filter.

    The Query Wizard adds the expression to the Generated CQL Statement as Figure 2-40 shows.

    Figure 2-40 Filter Configuration Dialog: After Adding the Filter

    Description of Figure 2-40 follows
    Description of "Figure 2-40 Filter Configuration Dialog: After Adding the Filter"

  23. Click Save.

  24. Click Save Query.

    Next you want to add a select statement.

  25. Click and drag a Select icon from the CQL Constructs palette and drop it anywhere in the Query Wizard canvas as Figure 2-41 shows.

    Figure 2-41 Query Wizard: Select

    Description of Figure 2-41 follows
    Description of "Figure 2-41 Query Wizard: Select"

  26. Click on the Filter icon and drag to the Select icon to connect the Oracle CQL constructs.

  27. Double-click the Select icon.

    The Select configuration screen appears.

    You want to select price, symbol, and volume from your StockVolGt1000 stream.

  28. Configure the Select as follows:

    • Select StockVolGt1000 from the Select a source pull-down menu.

    • Select the price property and click the Plus Sign button.

      The Query Wizard adds the property to Generated CQL Statement

    • Repeat for the symbol and volume properties.

    The Select configuration dialog appears as Figure 2-42 shows.

    Figure 2-42 Select Configuration Dialog: Properties Selected

    Description of Figure 2-42 follows
    Description of "Figure 2-42 Select Configuration Dialog: Properties Selected"

  29. Click Save.

  30. Click Save Query.

    Finally, you will add an Output.

  31. Click and drag an Output icon from the CQL Constructs palette and drop it anywhere in the Query Wizard canvas as Figure 2-43 shows.

    Figure 2-43 Query Wizard: Output

    Description of Figure 2-43 follows
    Description of "Figure 2-43 Query Wizard: Output"

  32. Click on the Select icon and drag to the Output icon to connect the Oracle CQL constructs.

  33. Double-click the Output icon.

    The Output configuration screen appears.

  34. Configure the Output as follows (as shown in Figure 2-44):

  35. Click Inject Rule.

    The Inject Rule Confirmation dialog appears as Figure 2-45 shows.

    Figure 2-45 Inject Rule Confirmation Dialog

    Description of Figure 2-45 follows
    Description of "Figure 2-45 Inject Rule Confirmation Dialog"

  36. Click OK.

    The Query Wizard adds the rule to the cqlProc processor.

  37. Click Save.

  38. Click on the CQL Rules tab.

    The CQL Rules tab appears as Figure 2-46 shows.

  39. Click on the View radio button.

    Confirm that your StockVolGt1000 view is present.

    Figure 2-46 CQL Rules Tab With View StockVolGt1000

    Description of Figure 2-46 follows
    Description of "Figure 2-46 CQL Rules Tab With View StockVolGt1000"

To create the moving average query using the view source:

  1. If the CQL Oracle Event Processing instance is not already running, follow the procedure in Section 2.6.1, "Running the CQL Example" to start the server.

    You must have a running server to use the Oracle Event Processing Visualizer.

  2. Invoke the following URL in your browser:

    http://host:port/wlevs
    

    where host refers to the name of the computer on which Oracle Event Processing is running and port refers to the Jetty NetIO port configured for the server (default value 9002).

    The Logon screen appears as Figure 2-47 shows.

    Figure 2-47 Oracle Event Processing Visualizer Logon Screen

    Description of Figure 2-47 follows
    Description of "Figure 2-47 Oracle Event Processing Visualizer Logon Screen"

  3. In the Logon screen, enter the User Id wlevs and Password wlevs, and click Log In.

    The Oracle Event Processing Visualizer dashboard appears as Figure 2-48 shows.

    Figure 2-48 Oracle Event Processing Visualizer Dashboard

    Description of Figure 2-48 follows
    Description of "Figure 2-48 Oracle Event Processing Visualizer Dashboard"

    For more information about the Oracle Event Processing Visualizer user interface, see "Understanding the Oracle Event Processing Visualizer User Interface" in the Oracle Fusion Middleware Visualizer User's Guide for Oracle Event Processing.

  4. In the left-hand pane, expand WLEventServerDomain > NonClusteredServer > Applications.

  5. Select the cql node.

    The CQL application screen appears as Figure 2-49 shows.

    Figure 2-49 CQL Application Screen: General Tab

    Description of Figure 2-49 follows
    Description of "Figure 2-49 CQL Application Screen: General Tab"

  6. Select the Event Processing Network tab.

    The Event Processing Network screen appears as Figure 2-50 shows.

    Figure 2-50 CQL Application: Event Processing Network Tab

    Description of Figure 2-50 follows
    Description of "Figure 2-50 CQL Application: Event Processing Network Tab"

  7. Double-click the stockProcessor Oracle CQL processor icon.

    The Oracle CQL processor screen appears as Figure 2-51 shows.

    Figure 2-51 Oracle CQL Processor: General Tab

    Description of Figure 2-51 follows
    Description of "Figure 2-51 Oracle CQL Processor: General Tab"

  8. Select the Query Wizard tab.

    The Query Wizard screen appears as Figure 2-52 shows. If you have been recently creating or editing queries for this processor, you might see those queries on the Query Wizard canvas. Otherwise, the canvas will be blank.

    Figure 2-52 Oracle CQL Processor: Query Wizard Tab

    Description of Figure 2-52 follows
    Description of "Figure 2-52 Oracle CQL Processor: Query Wizard Tab"

    You can use the Oracle CQL Query Wizard to construct an Oracle CQL query from a template or from individual Oracle CQL constructs.

    In this procedure, you are going to create an Oracle CQL view and query from individual Oracle CQL constructs.

    For more information, see "Creating a Rule in an Oracle CQL Processor Using the Query Wizard" in the Oracle Fusion Middleware Visualizer User's Guide for Oracle Event Processing.

  9. Click and drag an SSource icon (Stream Source) from the CQL Constructs palette and drop it anywhere in the Query Wizard canvas as Figure 2-53 shows.

    Figure 2-53 Query Wizard: SSource for Moving Average Query

    Description of Figure 2-53 follows
    Description of "Figure 2-53 Query Wizard: SSource for Moving Average Query"

  10. Double-click the SSource icon.

    The SSource configuration screen appears.

  11. Configure the SSource dialog as follows (as shown in Figure 2-54):

    • Select View as the Type.

    • Select the StockVolGt1000 view from the Select a source pull-down menu.

    Figure 2-54 SSource Configuration Dialog: Moving Average Query

    Description of Figure 2-54 follows
    Description of "Figure 2-54 SSource Configuration Dialog: Moving Average Query"

  12. Click Save.

  13. Click Save Query.

  14. Click and drag a Window icon from the CQL Constructs palette and drop it anywhere in the Query Wizard canvas as Figure 2-55 shows.

    Figure 2-55 Query Wizard: Window for Moving Average Query

    Description of Figure 2-55 follows
    Description of "Figure 2-55 Query Wizard: Window for Moving Average Query"

  15. Click on the SSource icon and drag to the Window icon to connect the Oracle CQL constructs.

  16. Double-click the Window icon.

    The SSource configuration screen appears.

    You want to create a sliding window over the last 2 events, partitioned by symbol.

  17. Configure the Window dialog as follows (as shown in Figure 2-56):

    • Select symbol in the Source Property List to add it to the Partition List.

    • Select Partition as the Type.

    • Select Row Based and enter 2 in the Row Based field.

  18. Click Add Window.

    The Query Wizard adds the sliding window to the Generated CQL Statement as Figure 2-56 shows.

    Figure 2-56 Window Configuration Dialog: After Adding Window

    Description of Figure 2-56 follows
    Description of "Figure 2-56 Window Configuration Dialog: After Adding Window"

  19. Click Save.

  20. Click Save Query.

  21. Click and drag a Select icon from the CQL Constructs palette and drop it anywhere in the Query Wizard canvas as Figure 2-57 shows.

    Figure 2-57 Query Wizard: Select for Moving Average Query

    Description of Figure 2-57 follows
    Description of "Figure 2-57 Query Wizard: Select for Moving Average Query"

  22. Click on the Window icon and drag to the Select icon to connect the Oracle CQL constructs.

  23. Double-click the Select icon.

    The Select configuration screen appears.

  24. Select StockVolGt1000 from the Select a source pull-down menu.

    This is the source of moving average query: the view you created earlier (see "To create a view source for the moving average query:").

  25. Select MovingAvgEvent from the Target Event Type pull-down menu.

    This is the output event your moving average query will produced. You will map properties from the source events to this output event.

  26. In the Source Properties list, select symbol.

    The selected source property is added to the Project Expression as Figure 2-58 shows.

    Figure 2-58 Select Configuration Dialog: Source Property symbol Selected

    Description of Figure 2-58 follows
    Description of "Figure 2-58 Select Configuration Dialog: Source Property symbol Selected"

    In this case, you just want to map the source property symbol to output event property symbol as is.

  27. Click on the pull-down menu next to the AS field and select symbol.

  28. Click the Plus Sign button.

    The source property is added to the project expression of the Generated CQL Statement as Figure 2-59 shows.

    Figure 2-59 Select Configuration Dialog: Source Property symbol Mapped to Output Event Property

    Description of Figure 2-59 follows
    Description of "Figure 2-59 Select Configuration Dialog: Source Property symbol Mapped to Output Event Property"

  29. In the Source Properties list, select price.

    The selected source property is added to the Project Expression as Figure 2-60 shows.

    Figure 2-60 Select Configuration Dialog: Source Property price Selected

    Description of Figure 2-60 follows
    Description of "Figure 2-60 Select Configuration Dialog: Source Property price Selected"

    In this case, you want to process the source property price before you map it to the output event.

  30. Click the Expression Builder button.

    The Expression Builder dialog appears.

  31. Select Aggregate Function from the Select a function type pull-down menu.

    A list of the aggregate functions that Oracle CQL provides is displayed. You are going to use the AVG function.

  32. Select the StockVolGt1000.price in the Expression Builder field.

  33. Double-click the AVG function.

    The AVG() function is wrapped around your selection in the Expression Builder field as Figure 2-61 shows.

    Figure 2-61 Expression Builder: Applying the AVG Function

    Description of Figure 2-61 follows
    Description of "Figure 2-61 Expression Builder: Applying the AVG Function"

  34. Click Save.

    The expression is added to the Project Expression field as Figure 2-62 shows.

    Figure 2-62 Select Configuration Dialog: With Expression

    Description of Figure 2-62 follows
    Description of "Figure 2-62 Select Configuration Dialog: With Expression"

  35. Click on the pull-down menu next to the AS field and select movingAvgPrice.

  36. Click the plus Sign button.

    The source property is added to the project expression of the Generated CQL Statement as Figure 2-63 shows.

    Figure 2-63 Select Configuration Dialog: Source Property price Mapped to Output Event Property

    Description of Figure 2-63 follows
    Description of "Figure 2-63 Select Configuration Dialog: Source Property price Mapped to Output Event Property"

  37. Click Validate.

    A validation error dialog is shown as Figure 2-64 shows.

    Figure 2-64 Validation Error: GROUP BY

    Description of Figure 2-64 follows
    Description of "Figure 2-64 Validation Error: GROUP BY"

    Because you are partitioning, you must specify a GROUP BY clause.

  38. Select the Group tab.

    The Group tab appears.

  39. Configure the Group tab as follows (as shown in Figure 2-65):

    • Select StockVolGt1000 from the Select a source pull-down menu.

    • Select symbol from the Properties list.

    • Click the Plus Sign button.

    The symbol property is added to GROUP BY clause as Figure 2-65 shows.

    Figure 2-65 Group Tab: With symbol Grouping Property

    Description of Figure 2-65 follows
    Description of "Figure 2-65 Group Tab: With symbol Grouping Property"

  40. Click Save.

  41. Click Save Query.

    Next, you want to connect the query to an output.

  42. Click and drag an Output icon from the CQL Constructs palette and drop it anywhere in the Query Wizard canvas as Figure 2-66 shows.

    Figure 2-66 Query Wizard: Output

    Description of Figure 2-66 follows
    Description of "Figure 2-66 Query Wizard: Output"

  43. Click on the Select icon and drag to the Output icon to connect the Oracle CQL constructs.

  44. Double-click the Output icon.

    The Output configuration screen appears.

  45. Configure the Output as follows (as shown in Figure 2-67):

    • Select Query.

    • Enter MovingAverage as the Query Name.

    Figure 2-67 Output Configuration Dialog

    Description of Figure 2-67 follows
    Description of "Figure 2-67 Output Configuration Dialog"

  46. Click Inject Rule.

    The Inject Rule Confirmation dialog appears as Figure 2-68 shows.

    Figure 2-68 Inject Rule Confirmation Dialog

    Description of Figure 2-68 follows
    Description of "Figure 2-68 Inject Rule Confirmation Dialog"

  47. Click OK.

    The Query Wizard adds the rule to the cqlProc processor.

  48. Click Save.

  49. Click on the CQL Rules tab.

    The CQL Rules tab appears as Figure 2-69 shows.

  50. Click on the Query radio button.

    Confirm that your MovingAverage query is present.

    Figure 2-69 CQL Rules Tab With View MovingAverage

    Description of Figure 2-69 follows
    Description of "Figure 2-69 CQL Rules Tab With View MovingAverage"

To test the moving average query:

  1. To simulate the data feed for the moving average query, open a new command window and set your environment as described in Section 3.2, "Setting Your Development Environment."

  2. Change to the MIDDLEWARE_HOME\ocep_11.1\utils\load-generator directory, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

  3. Run the load generator using the stockData.prop properties file:

    1. On Windows:

      prompt> runloadgen.cmd stockData.prop
      
    2. On UNIX:

      prompt> runloadgen.sh stockData.prop
      
  4. In the Oracle Event Processing Visualizer, click the ViewStream button in the top pane.

    The Stream Visualizer screen appears as Figure 2-70 shows.

    Figure 2-70 Stream Visualizer: Showing Moving Average Query Output

    Description of Figure 2-70 follows
    Description of "Figure 2-70 Stream Visualizer: Showing Moving Average Query Output"

  5. Click Initialize Client.

  6. Enter /stockmoving in the Initialize client field.

  7. Click Subscribe.

    As the moving average query outputs events, the Oracle Event Processing updates the Received Messages area showing the events generated.

2.7 Oracle Spatial Example

This example shows how to use Oracle Spatial with Oracle CQL queries to process a stream of Global Positioning System (GPS) events to track the GPS location of buses and generate alerts when a bus arrives at its pre-determined bus stop positions.

Figure 2-71 shows Oracle Spatial example Event Processing Network (EPN). The EPN contains the components that make up the application and how they fit together.

Figure 2-71 Oracle Spatial Example Event Processing Network

Description of Figure 2-71 follows
Description of "Figure 2-71 Oracle Spatial Example Event Processing Network"

The example includes the following components:

Note:

For more information about data cartridges, see:

2.7.1 Running the Oracle Spatial Example

The Oracle Spatial application is pre-deployed to the spatial_domain domain. To run the application, you simply start an instance of Oracle Event Processing server.

To run the Oracle Spatial example from the spatial_domain domain:

  1. Open a command window and change to the default server directory of the Oracle Spatial example domain directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\domains\spatial_domain\defaultserver, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

    prompt> cd d:\Oracle iddleware\ocep_11.1\samples\domains\spatial_domain\defaultserver
    
  2. Ensure the environment is set correctly in the server startup script.

    For more information, see Chapter 3, "Getting Started with Developing Oracle Event Processing Applications"

  3. Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:

    1. On Windows:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.cmd -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.cmd
        
    2. On UNIX:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.sh -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.sh
        

    Wait for the console log to show:

    <Mar 4, 2010 2:13:15 PM EST> <Notice> <Spring> <BEA-2047000> <The application context for "spatial_sample" was started successfully>
    <Mar 4, 2010 2:13:15 PM EST> <Notice> <Server> <BEA-2046000> <Server STARTED>
    

    This message indicates that the Oracle Spatial example is running correctly.

  4. On the same host as the Oracle Spatial example is running, launch a browser and navigate to http://localhost:9002/bus/main.html.

    Note:

    You cannot run this example on one host and browse to it from another host. This is a limitation of the Google API Key that the example uses and is not a limitation of Oracle Event Processing.

    The Oracle Spatial example Web page appears as Figure 2-72 shows.

    Figure 2-72 Oracle Spatial Web Page

    Description of Figure 2-72 follows
    Description of "Figure 2-72 Oracle Spatial Web Page"

    Click the Bus Top Arrivals tab to view bus stop arrivals as Figure 2-73 shows.

    Figure 2-73 Oracle Spatial Web Page: Bus Stop Arrivals Tab

    Description of Figure 2-73 follows
    Description of "Figure 2-73 Oracle Spatial Web Page: Bus Stop Arrivals Tab"

  5. Execute the Oracle Event Processing load generator to generate sample data:

    1. On Windows:

      • Open a command prompt and navigate to MIDDLEWARE_HOME/ocep_11.1/utils/load-generator

      • runloadgen.cmd bus_positions.prop

    2. On UNIX:

      • Open a terminal window and navigate to MIDDLEWARE_HOME/ocep_11.1/utils/load-generator

      • runloadgen.sh bus_positions.prop

  6. Observe the bus movements and alerts in the browser as Figure 2-74 shows.

    Figure 2-74 Oracle Spatial Web Page: Bus Tracking

    Description of Figure 2-74 follows
    Description of "Figure 2-74 Oracle Spatial Web Page: Bus Tracking"

2.7.2 Building and Deploying the Oracle Spatial Example

The Oracle Spatial sample source directory contains the Java source, along with other required resources such as configuration XML files, that make up the Oracle Spatial application. The build.xml Ant file contains targets to build and deploy the application to the spatial_domain domain.

For more information, see Section 2.5.3, "Description of the Ant Targets to Build Hello World".

To build and deploy the Oracle Spatial example from the source directory:

  1. If the spatial_domain Oracle Event Processing instance is not already running, follow the procedure in Section 2.7.1, "Running the Oracle Spatial Example" to start the server.

    You must have a running server to successfully deploy the rebuilt application.

  2. Open a new command window and change to the Oracle Spatial source directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\source\applications\spatial where MIDDLEWARE_HOME is the Middleware directory you specified when you installed Oracle Event Processing.

    For example:

    prompt> cd d:\Oracle\Middleware\ocep_11.1\samples\source\applications\spatial
    
  3. Set your development environment as described in Section 3.2, "Setting Your Development Environment."

  4. Execute the all Ant target to compile and create the application JAR file:

    prompt> ant all
    
  5. Execute the deploy Ant target to deploy the application JAR file to Oracle Event Processing:

    prompt> ant -Daction=update deploy
    

    Caution:

    This target overwrites the existing Oracle Spatial application JAR file in the domain directory.

2.7.3 Description of the Ant Targets to Build the Oracle Spatial Example

The build.xml file, located in the top level of the Oracle Spatial source directory, contains the following targets to build and deploy the application:

  • clean—This target removes the dist and output working directories under the current directory.

  • all—This target cleans, compiles, and JARs up the application into a file called com.bea.wlevs.example.helloworld_11.1.1.4_0.jar, and places the generated JAR file into a dist directory below the current directory.

  • deploy—This target deploys the JAR file to Oracle Event Processing using the Deployer utility.

    For more information, see "Deployer Command-Line Reference" in the Oracle Fusion Middleware Administrator's Guide for Oracle Event Processing.

2.7.4 Implementation of the Oracle Spatial Example

The implementation of the Oracle Spatial example generally follows "Creating Oracle Event Processing Applications: Typical Steps" in the Oracle Fusion Middleware Developer's Guide for Oracle Event Processing for Eclipse.

Refer to that section for a task-oriented procedure that describes the typical development process.

All the files of the Oracle Spatial example are located relative to the MIDDLEWARE_HOME\ocep_11.1\samples\source\applications\spatial directory, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing, such as c:\Oracle\Middleware. Oracle recommends that you use this example directory setup in your own environment, although it is obviously not required.

The files used by the Oracle Spatial example include:

  • An EPN assembly file that describes each component in the application and how all the components are connected together. You are required to include this XML file in your Oracle Event Processing application.

    In the example, the file is called context.xml and is located in the META-INF/spring directory.

  • A component configuration file that configures the various components on the EPN including the processor component of the application:

    In the example, this file is called config.xml and is located in the META-INF/wlevs directory.

  • Java files that implement:

    • BusStopAdapter: Custom adapter component that generates bus stop positions based on MIDDLEWARE_HOME\ocep_11.1\samples\domains\spatial_domain\defaultserver\applications\spatial_sample\bus_stops.csv, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

    • OutputBean: POJO event bean component that logs a message for each insert, delete, and update event to help visualize the relation offered by the BusStopArrivalChannel

    • OrdsHelper: Helper class that provides method getOrds to return the ordinates from a JGeometry as a List of Double values.

    These Java files are located in the source\applications\spatial\src\com\oracle\cep\sample\spatial directory.

    For additional information about the Oracle Event Processing APIs referenced in this POJO, see Oracle Fusion Middleware Java API Reference for Oracle Event Processing.

  • A MANIFEST.MF file that describes the contents of the OSGi bundle that will be deployed to Oracle Event Processing.

    In the example, the MANIFEST.MF file is located in the META-INF directory.

    For more information about creating this file, as well as a description of creating the OSGi bundle that you deploy to Oracle Event Processing, see Section 23.1, "Overview of Application Assembly and Deployment".

    The Oracle Spatial example uses a build.xml Ant file to compile, assemble, and deploy the OSGi bundle; see Section 2.7.2, "Building and Deploying the Oracle Spatial Example" for a description of this build.xml file if you also use Ant in your development environment.

2.8 Foreign Exchange (FX) Example

The foreign exchange example, called FX for simplicity, is a more complex example than the HelloWorld example because it includes multiple processors that handle information from multiple data feeds. In the example, the data feeds are simulated using the Oracle Event Processing load generator utility.

Figure 2-75 shows the FX example Event Processing Network (EPN). The EPN contains the components that make up the application and how they fit together.

Figure 2-75 FX Example Event Processing Network

Description of Figure 2-75 follows
Description of "Figure 2-75 FX Example Event Processing Network"

In this scenario, three data feeds, simulated using the load generator, send a constant pair of values from different parts of the world; the value pairs consist of a currency pair, such as USDEUR for US dollar - European euro, and an exchange rate between the two currencies. The fxMarketAmer, fxMarketAsia, and fxMarketEuro adapters receive the data from the feeds, convert them into events, and pass them to the corresponding FilterAmer, FilterAsia, and FilterEuro processors. Each processor performs an initial stale check to ensure that no event is more than 1 second old and then a boundary check to ensure that the exchange rate between the two currencies is within a current boundary. The processor also only selects a specific currency pair from a particular channel; for example, the server selects USDEUR from the simulated American data feed, but rejects all other pairs, such as USDAUD (Australian dollar).

After the data from each data feed provider passes this initial preparation phase, a different processor, called FindCrossRate, joins all events across all providers, calculates the mid-point between the maximum and minimum rate, and then applies a trader-specified spread. Finally, the processor forwards the rate to the POJO that contains the business code; in this example, the POJO simply publishes the rate to clients.

The Oracle Event Processing monitor is configured to watch if the event latency in the last step exceeds some threshold, such as no updated rates in a 30 second time-span, and if there is too much variance between two consecutive rates for the same currency pair. Finally, the last rate of each currency pair is forwarded to the Oracle Event Processing http pub-sub server.

2.8.1 Running the Foreign Exchange Example

For optimal demonstration purposes, Oracle recommends that you run this example on a powerful computer, such as one with multiple CPUs or a 3 GHz dual-core Intel, with a minimum of 2 GB of RAM.

The Foreign Exchange (FX) application is pre-deployed to the fx_domain domain. To run the application, you simply start an instance of Oracle Event Processing server.

To run the foreign exchange example:

  1. Open a command window and change to the default server directory of the FX domain directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\domains\fx_domain\defaultserver, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

    prompt> cd d:\Oracle iddleware\ocep_11.1\samples\domains\fx_domain\defaultserver
    
  2. Set your development environment, as described in Section 3.2, "Setting Your Development Environment."

  3. Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:

    1. On Windows:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.cmd -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.cmd
        
    2. On UNIX:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.sh -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.sh
        

    The FX application is now ready to receive data from the data feeds.

  4. To simulate an American data feed, open a new command window and set your environment as described in Section 3, "Getting Started with Developing Oracle Event Processing Applications."

  5. Change to the MIDDLEWARE_HOME\ocep_11.1\utils\load-generator directory, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

  6. Run the load generator using the fxAmer.prop properties file:

    1. On Windows:

      prompt> runloadgen.cmd fxAmer.prop
      
    2. On UNIX:

      prompt> runloadgen.sh fxAmer.prop
      
  7. Repeat steps 4 - 6 to simulate an Asian data feed, using the fxAsia.prop properties file:

    1. On Windows:

      prompt> runloadgen.cmd fxAsia.prop
      
    2. On UNIX:

      prompt> runloadgen.sh fxAsia.prop
      
  8. Repeat steps 4 - 6 to simulate an European data feed, using the fxEuro.prop properties file:

    1. On Windows:

      prompt> runloadgen.cmd fxEuro.prop
      
    2. On UNIX:

      prompt> runloadgen.sh fxEuro.prop
      

    After the server status messages scroll by in the command window from which you started the server, and the three load generators start, you should see messages similar to the following being printed to the server command window (the message will likely be on one line):

    OutputBean:onEvent() + 
        <TupleValue>
            <EventType>SpreaderOuputEvent</EventType>
            <ObjectName>FindCrossRatesRule</ObjectName>
            <Timestamp>1843704855846</Timestamp>
            <TupleKind>null</TupleKind>
            <DoubleAttribute>
                <Value>90.08350000074516</Value>
            </DoubleAttribute>
            <CharAttribute>
                <Value>USD</Value>
                <Length>3</Length>
            </CharAttribute>
            <CharAttribute>
                <Value>JPY</Value>
                <Length>3</Length>
            </CharAttribute>
        <IsTotalOrderGuarantee>false</IsTotalOrderGuarantee>
    </TupleValue>
    

    These messages indicate that the Foreign Exchange example is running correctly. The output shows the cross rates of US dollars to Japanese yen and US dollars to UK pounds sterling.

2.8.2 Building and Deploying the Foreign Exchange Example from the Source Directory

The Foreign Exchange (FX) sample source directory contains the Java source, along with other required resources such as configuration XML files, that make up the FX application. The build.xml Ant file contains targets to build and deploy the application to the fx_domain domain, as described in Section 2.5.3, "Description of the Ant Targets to Build Hello World."

To build and deploy the foreign exchange example from the source directory:

  1. If the FX Oracle Event Processing instance is not already running, follow the procedure in Section 2.8.1, "Running the Foreign Exchange Example" to start the server.

    You must have a running server to successfully deploy the rebuilt application.

  2. Open a new command window and change to the FX source directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\source\applications\fx, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing installation directory, such as d:\Oracle\Middleware.

    prompt> cd d:\Oracle\Middleware\ocep_11.1\samples\source\applications\fx
    
  3. Set your development environment, as described in Section 3.2, "Setting Your Development Environment."

  4. Execute the all Ant target to compile and create the application JAR file:

    prompt> ant all
    
  5. Execute the deploy Ant target to deploy the application JAR file to Oracle Event Processing:

    prompt> ant -Dusername=wlevs -Dpassword=wlevs -Daction=update deploy
    

    Caution:

    This target overwrites the existing FX application JAR file in the domain directory.

  6. If the load generators required by the FX application are not running, start them as described in Section 2.8.1, "Running the Foreign Exchange Example."

    After server status messages scroll by, you should see the following message printed to the output:

    {crossRate=USDJPY, internalPrice=119.09934499999781}, {crossRate=USDGBP, internalPrice=0.5031949999999915}, {crossRate=USDJPY, internalPrice=117.73945624999783}
    

    This message indicates that the FX example has been redeployed and is running correctly.

2.8.3 Description of the Ant Targets to Build FX

The build.xml file, located in the top-level directory of the FX source, contains the following targets to build and deploy the application:

  • clean—This target removes the dist and output working directories under the current directory.

  • all—This target cleans, compiles, and jars up the application into a file called com.bea.wlevs.example.fx_11.1.1.4_0.jar, and places the generated JAR file into a dist directory below the current directory.

  • deploy—This target deploys the JAR file to Oracle Event Processing using the Deployer utility.

    For more information, see "Deployer Command-Line Reference" in the Oracle Fusion Middleware Administrator's Guide for Oracle Event Processing.

2.8.4 Implementation of the FX Example

The implementation of the foreign exchange (FX) example generally follows "Creating Oracle Event Processing Applications: Typical Steps" in the Oracle Fusion Middleware Developer's Guide for Oracle Event Processing for Eclipse.

Refer to that section for a task-oriented procedure that describes the typical development process.

All the files of the FX example are located relative to the MIDDLEWARE_HOME\ocep_11.1\samples\source\applications\fx directory, where MIDDLEWARE_HOME is the Middleware home directory you specified when you installed Oracle Event Processing c:\Oracle\Middleware. Oracle recommends that you use this example directory setup in your own environment, although it is obviously not required.

The files used by the FX example include:

  • An EPN assembly file that describes each component in the application and how all the components are connected together. You are required to include this XML file in your Oracle Event Processing application.

    In the example, the file is called com.oracle.cep.sample.fx.context.xml and is located in the META-INF/spring directory.

  • Two XML files that configure the processor components of the application:

    The first XML file configures the filterAmer, filterAsia, filterEuro, and FindCrossRates processors, all in a single file. This XML file includes the Oracle CQL rules that select particular currency pairs from particular simulated market feeds and joins together all the events that were selected by the pre-processors, calculates an internal price for the particular currency pair, and then calculates the cross rate. In the example, this file is called spreader.xml and is located in the META-INF/wlevs directory.

    The second XML file configures the summarizeResults processor and includes the Oracle CQL rule that summarizes the results of the FindCrossRates processor. In the example, this file is called SummarizeResults.xml and is located in the META-INF/wlevs directory.

  • An XML file that configures the PublishSummaryResults http pub-sub adapter. In the example, this file is called PubSubAdapterConfiguration.xml and is located in the META-INF/wlevs directory.

  • A Java file that implements the OutputBean component of the application, a POJO that contains the business logic. This POJO prints out to the screen the events that it receives, programmed in the onEvent method. The POJO also registers into the event type repository the ForeignExchangeEvent event type.

    In the example, the file is called OutputBean.java and is located in the src/com/oracle/cep/sample/fx directory.

    For additional information about the Oracle Event Processing APIs referenced in this POJO, see Oracle Fusion Middleware Java API Reference for Oracle Event Processing.

  • A MANIFEST.MF file that describes the contents of the OSGi bundle that will be deployed to Oracle Event Processing.

    In the example, the MANIFEST.MF file is located in the META-INF directory.

    For more information about creating this file, as well as a description of creating the OSGi bundle that you deploy to Oracle Event Processing, see Section 23.1, "Overview of Application Assembly and Deployment".

    The FX example uses a build.xml Ant file to compile, assemble, and deploy the OSGi bundle; see Section 2.8.2, "Building and Deploying the Foreign Exchange Example from the Source Directory" for a description of this build.xml file if you also use Ant in your development environment.

2.9 Signal Generation Example

The signal generation sample application receives simulated market data and verifies if the price of a security has fluctuated more than two percent. The application also detects the pattern occurring by keeping track of successive stock prices for a particular symbol; if more than three successive prices are larger than the one before it, this is considered a pattern.

Figure 2-76 shows the signal generation example Event Processing Network (EPN). The EPN contains the components that make up the application and how they fit together.

Figure 2-76 The Signal Generation Example Event Processing Network

Description of Figure 2-76 follows
Description of "Figure 2-76 The Signal Generation Example Event Processing Network"

The application simulates a market data feed using the Oracle Event Processing load generator utility; in this example, the load generator generates up to 10,000 messages per second. The example includes an HTML dashboard which displays the matched events along with the latencies; events consist of a stock symbol, a timestamp, and the price.

The example demonstrates very low latencies, with minimum latency jitter under high throughputs. Once the application starts running, the processor matches an average of 800 messages per second. If the application is run on the minimum configured system, the example shows very low average latencies (30-300 microsecond, on average) with minimal latency spikes (low milliseconds).

The example computes and displays latency values based on the difference between a timestamp generated on the load generator and timestamp on Oracle Event Processing. Computing valid latencies requires very tight clock synchronization, such as 1 millisecond, between the computer running the load generator and the computer running Oracle Event Processing. For this reason, Oracle recommends running both the load generator and Oracle Event Processing on a single multi-CPU computer where they will share a common clock.

The example also shows how to use the Oracle Event Processing event caching feature. In particular the single processor in the EPN sends events to both an event bean and a cache.

The example also demonstrates how to use Oracle CQL queries.

2.9.1 Running the Signal Generation Example

For optimal demonstration purposes, Oracle recommends that you run this example on a powerful computer, such as one with multiple CPUs or a 3 GHz dual-core Intel, with a minimum of 2 GB of RAM.

The signalgeneration_domain domain contains a single application: the signal generation sample application. To run the signal generation application, you simply start an instance of Oracle Event Processing in that domain.

To run the signal generation example:

  1. Open a command window and change to the default server directory of the signalgeneration_domain domain directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\domains\signalgeneration_domain\defaultserver, where MIDDLEWARE_HOME refers to the Middleware home directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

    prompt> cd d:\Oracle\Middleware\ocep_11.1\samples\domains\signalgeneration_domain\defaultserver
    
  2. Set your development environment, as described in Section 3.2, "Setting Your Development Environment."

  3. Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:

    1. On Windows:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.cmd -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.cmd
        
    2. On UNIX:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.sh -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.sh
        
  4. Wait until you see console messages like this:

    <Apr 24, 2009 11:40:37 AM EDT> <Notice> <Server> <BEA-2046000> <Server STARTED>
    Throughput (msg per second): 0. Average latency (microseconds): 0
    Throughput (msg per second): 0. Average latency (microseconds): 0
    Throughput (msg per second): 0. Average latency (microseconds): 0
    Throughput (msg per second): 0. Average latency (microseconds): 0
    ...
    

    The signal generation application is now ready to receive data from the data feeds.

    Next, to simulate a data feed, you use a load generator programmed specifically for the example.

  5. 0pen a new command window.

  6. Change to the MIDDLEWARE_HOME\ocep_11.1\samples\domains\signalgeneration_domain\defaultserver\utils directory, where MIDDLEWARE_HOME refers to the Middleware home directory you specified when you installed Oracle Event Processing, such as d:Oracle\Middleware.

  7. Run the startDataFeed command:

    1. On Windows:

      prompt> startDataFeed.cmd
      
    2. On UNIX:

      prompt> startDataFeed.sh
      
  8. Invoke the example dashboard by starting a browser and opening the following HTML page:

    http://host:9002/signalgeneration/dashboard.html
    

    Replace host with the name of the computer on which Oracle Event Processing is running; if it is the same computer as your browser, you can use localhost.

  9. In the browser, click Start on the HTML page.

    You should start seeing the events that match the Oracle CQL rules configured for this example as Figure 2-77 shows.

    Figure 2-77 Signal Generation Dashboard

    Description of Figure 2-77 follows
    Description of "Figure 2-77 Signal Generation Dashboard"

2.9.2 Building and Deploying the Signal Generation Example from the Source Directory

The signal generation sample source directory contains the Java source, along with other required resources, such as configuration XML files, EPN assembly file, and DOJO client JavaScript libraries, that make up the signal generation application. The build.xml Ant file contains targets to build and deploy the application to the signalgeneration_domain domain, as described in Section 2.9.3, "Description of the Ant Targets to Build Signal Generation."

To build and deploy the signal generation example from the source directory:

  1. If the signal generation Oracle Event Processing instance is not already running, follow the procedure in Section 2.9.1, "Running the Signal Generation Example" to start the server. You must have a running server to successfully deploy the rebuilt application.

  2. Open a new command window and change to the signal generation source directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\source\applications\signalgeneration, where MIDDLEWARE_HOME refers to the Middleware home directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

    prompt> cd d:\Oracle\Middleware\ocep_11.1\samples\source\applications\signalgeneration
    
  3. Set your development environment, as described in Section 3.2, "Setting Your Development Environment."

  4. Execute the all Ant target to compile and create the application JAR file:

    prompt> ant all
    
  5. Execute the deploy Ant target to deploy the application JAR file to the MIDDLEWARE_HOME\ocep_11.1\samples\domains\signalgeneration_domain\defaultserver\applications\signalgeneration directory:

    prompt> ant deploy
    

    Caution:

    This target overwrites the existing signal generation application JAR file in the domain directory.

  6. If the load generator required by the signal generation application is not running, start it as described in Section 2.9.1, "Running the Signal Generation Example."

  7. Invoke the example dashboard as described in Section 2.9.1, "Running the Signal Generation Example."

2.9.3 Description of the Ant Targets to Build Signal Generation

The build.xml file, located in the top-level directory of the signal generation example source, contains the following targets to build and deploy the application:

  • clean—This target removes the dist and output working directories under the current directory.

  • all—This target cleans, compiles, and jars up the application into a file called com.bea.wlevs.example.signalgen_11.1.1.4_0.jar, and places the generated JAR file into a dist directory below the current directory.

  • deploy—This target deploys the JAR file to Oracle Event Processing using the Deployer utility.

    For more information, see "Deployer Command-Line Reference" in the Oracle Fusion Middleware Administrator's Guide for Oracle Event Processing.

2.9.4 Implementation of the Signal Generation Example

The implementation of the signal generation example generally follows "Creating Oracle Event Processing Applications: Typical Steps" in the Oracle Fusion Middleware Developer's Guide for Oracle Event Processing for Eclipse.

Refer to that section for a task-oriented procedure that describes the typical development process.

All the files of the signal generation are located relative to the MIDDLEWARE_HOME\ocep_11.1\samples\source\applications\signalgeneration directory, where MIDDLEWARE_HOME refers to the Middleware home directory you specified when you installed Oracle Event Processing, such as c:\Oracle\Middleware. Oracle recommends that you use this example directory setup in your own environment, although it is obviously not required.

The files used by the signal generation example include:

  • A EPN assembly file that describes each component in the application and how all the components are connected together.

    In the example, the file is called epn_assembly.xml and is located in the META-INF/spring directory.

  • An XML file that configures the processor component of the application; this file is called config.xml and is located in the META-INF/wlevs directory

    The config.xml file configures the processor1 Oracle CQL processor, in particular the Oracle CQL rules that verify whether the price of a security has fluctuated more than two percent and whether a trend has occurred in its price.

  • A Java file that implements the SignalgenOutputBean component of the application, a POJO that contains the business logic. This POJO is an HttpServlet and an EventSink. Its onEvent method consumes PercentTick and TrendTick event instances, computes latency, and displays dashboard information.

    In the example, the file is called SignalgenOutputBean.java and is located in the src/oracle/cep/example/signalgen directory.

    For general information about programming event sinks, see Section 16.2, "Handling Events with Sources and Sinks".

  • A MANIFEST.MF file that describes the contents of the OSGi bundle that will be deployed to Oracle Event Processing.

    In the example, the MANIFEST.MF file is located in the META-INF directory

    For more information about creating this file, as well as a description of creating the OSGi bundle that you deploy to Oracle Event Processing, see Section 23.1, "Overview of Application Assembly and Deployment".

  • A dashboard.html file in the main example directory; this HTML file is the example dashboard that displays events and latencies of the running signal generation application. The HTML file uses Dojo JavaScript libraries from http://dojotoolkit.org/, located in the dojo directory.

For additional information about the Oracle Event Processing APIs referenced in ForeignExchangeBuilderFactory, see Oracle Fusion Middleware Java API Reference for Oracle Event Processing.

The signal generation example uses a build.xml Ant file to compile, assemble, and deploy the OSGi bundle; see Section 2.9.2, "Building and Deploying the Signal Generation Example from the Source Directory" for a description of this build.xml file if you also use Ant in your development environment.

2.10 Event Record and Playback Example

The record and playback example shows how to configure a component to record events to an event store and then configure another component in the network to playback events from the store. The example uses the Oracle Event Processing-provided default Berkeley database to store the events. The example also shows how to configure a publishing HTTP pub-sub adapter as a node in the event processing network.

Figure 2-78 shows the event record and playback example Event Processing Network (EPN). The EPN contains the components that make up the application and how they fit together.

Figure 2-78 The Event Record and Playback Example Event Processing Network

Description of Figure 2-78 follows
Description of "Figure 2-78 The Event Record and Playback Example Event Processing Network"

The application contains four components in its event processing network:

2.10.1 Running the Event Record/Playback Example

The recplay_domain domain contains a single application: the record and playback sample application. To run this application, you first start an instance of Oracle Event Processing in the domain, as described in the following procedure.

The procedure then shows you how to use Oracle Event Processing Visualizer to start the recording and playback of events at the simpleEventSource and eventStream components, respectively. Finally, the procedure shows you how to use Oracle Event Processing Visualizer to view the stream of events being published to a channel by the playbackHttpPublisher adapter.

To run the event record/playback example:

  1. Open a command window and change to the default server directory of the recplay_domain domain directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\domains\recplay_domain\defaultserver, where MIDDLEWARE_HOME refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

    prompt> cd d:\Oracle\Middleware\ocep_11.1\samples\domains\recplay_domain\defaultserver
    
  2. Set your development environment, as described in Section 3.2, "Setting Your Development Environment."

  3. Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:

    1. On Windows:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.cmd -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.cmd
        
    2. On UNIX:

      • If you are using the JRockit JDK included in Oracle JRockit Real Time, enable the deterministic garbage collector by passing the -dgc parameter to the command:

        prompt> startwlevs.sh -dgc
        
      • If you are not using the JRockit JDK included in Oracle JRockit Real Time:

        prompt> startwlevs.sh
        

    After server status messages scroll by, you should see the following message printed to the output:

    SimpleEvent created at: 14:33:40.441
    

    This message indicates that the Oracle Event Processing server started correctly and that the simpleEventSource component is creating events.

  4. Invoke the following URL in your browser:

    http://host:port/wlevs
    

    where host refers to the name of the computer on which Oracle Event Processing is running and port refers to the Jetty NetIO port configured for the server (default value 9002).

    The Logon screen appears as Figure 2-79 shows.

    Figure 2-79 Oracle Event Processing Visualizer Logon Screen

    Description of Figure 2-79 follows
    Description of "Figure 2-79 Oracle Event Processing Visualizer Logon Screen"

  5. In the Logon screen, enter the User Id wlevs and Password wlevs, and click Log In.

    The Oracle Event Processing Visualizer dashboard appears as Figure 2-80 shows.

    Figure 2-80 Oracle Event Processing Visualizer Dashboard

    Description of Figure 2-80 follows
    Description of "Figure 2-80 Oracle Event Processing Visualizer Dashboard"

    For more information about the Oracle Event Processing Visualizer user interface, see "Understanding the Oracle Event Processing Visualizer User Interface" in the Oracle Fusion Middleware Visualizer User's Guide for Oracle Event Processing.

  6. In the left pane, select WLEventServerDomain > NonClusteredServer > Applications > recplay > Stages > simpleEventSource.

  7. In the right pane, select the Record tab as shown in Figure 2-81.

    Figure 2-81 Event Record Tab

    Description of Figure 2-81 follows
    Description of "Figure 2-81 Event Record Tab"

    The DataSet Name field contains the value of the record-parameters child element dataset-name element from the simpleEventSource adapter application configuration file MIDDLEWARE_HOME\ocep_11.1\samples\domains\recplay_domain\defaultserver\applications\recplay\config.xml as Example 2-1 shows.

    Example 2-1 recplay Application Configuration File config.xml: adapter Element

    <adapter>
        <name>simpleEventSource</name>
        <record-parameters>
            <dataset-name>recplay_sample</dataset-name>
            <event-type-list>
                <event-type>SimpleEvent</event-type>
            </event-type-list>
            <batch-size>1</batch-size>
            <batch-time-out>10</batch-time-out>
        </record-parameters>
    </adapter>
    
  8. At the bottom of the Record tab, click Start.

    An Alert dialog appears as shown in Figure 2-82.

    Figure 2-82 Start Recording Alert Dialog

    Description of Figure 2-82 follows
    Description of "Figure 2-82 Start Recording Alert Dialog"

  9. Click OK.

    The Current Status field reads Recording....

    As soon as you click OK, events start to flow out of the simpleEventSource component and are stored in the configured database.

    You can further configure when events are recorded using the Start Recording and Stop Recording fields.

  10. In the left pane, select eventStream.

  11. In the right pane, select the Playback tab as shown in Figure 2-83.

    Figure 2-83 Event Playback Tab

    Description of Figure 2-83 follows
    Description of "Figure 2-83 Event Playback Tab"

  12. At the bottom of the tab, click Start.

    An Alert dialog appears as shown in Figure 2-84.

    Figure 2-84 Start Playback Alert Dialog

    Description of Figure 2-84 follows
    Description of "Figure 2-84 Start Playback Alert Dialog"

  13. Click OK.

    The Current Status field reads Playing....

    As soon as you click OK, events that had been recorded by the simpleEventSource component are now played back to the simpleStream component.

    You should see the following messages being printed to the command window from which you started Oracle Event Processing server to indicate that both original events and playback events are streaming through the EPN:

    SimpleEvent created at: 14:33:11.501
    Played back: Original time=14:15:23.141 Playback time=14:33:11.657
    

    You can further configure the playback parameters, such as the recorded time period for which you want playback events and the speed that they are played back, by updating the appropriate field and clicking Change Parameters. You must restart the playback after changing any playback parameters.

  14. To view the events that the playbackHttpPublisher adapter is publishing to a channel, follow these steps:

    1. In the top pane, select Viewstream.

      The Viewstream window appears as shown in Figure 2-85.

      Figure 2-85 Stream Visualizer

      Description of Figure 2-85 follows
      Description of "Figure 2-85 Stream Visualizer"

    2. In the right pane, click Initialize Client.

    3. In the Subscribe Channel text box, enter /playbackchannel.

    4. Click Subscribe.

    The Received Messages text box displays the played back event details. The played back events show the time at which the event was created and the time at which it was played back.

2.10.2 Building and Deploying the Event Record/Playback Example from the Source Directory

The record and playback sample source directory contains the Java source, along with other required resources, such as configuration XML file and EPN assembly file that make up the application. The build.xml Ant file contains targets to build and deploy the application to the signalgeneration_domain domain, as described in Section 2.10.3, "Description of the Ant Targets to Build the Record and Playback Example."

To build and deploy the event record/playback example from the source directory:

  1. If the record/playback Oracle Event Processing instance is not already running, follow the procedure in Section 2.10.1, "Running the Event Record/Playback Example" to start the server. You must have a running server to successfully deploy the rebuilt application.

  2. Open a new command window and change to the record/playback source directory, located in MIDDLEWARE_HOME\ocep_11.1\samples\source\applications\recplay, where MIDDLEWARE_HOME refers to the Middleware home directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

    prompt> cd d:\Oracle\Middleware\ocep_11.1\samples\source\applications\recplay
    
  3. Set your development environment, as described in Section 3.2, "Setting Your Development Environment."

  4. Execute the all Ant target to compile and create the application JAR file:

    prompt> ant all
    
  5. Execute the deploy Ant target to deploy the application JAR file to the MIDDLEWARE_HOME\ocep_11.1\samples\domains\recplay_domain\defaultserver\applications\recplay directory:

    prompt> ant -Dusername=wlevs -Dpassword=wlevs -Daction=update deploy
    

    Caution:

    This target overwrites the existing event record/playback application JAR file in the domain directory.

    After an application redeploy message, you should see the following message printed to the output about every second:

    SimpleEvent created at: 14:33:40.441
    

    This message indicates that the record and playback example has been redeployed and is running correctly.

  6. Follow the instructions in Section 2.10.1, "Running the Event Record/Playback Example," starting at step 4, to invoke Oracle Event Processing Visualizer and start recording and playing back events.

2.10.3 Description of the Ant Targets to Build the Record and Playback Example

The build.xml file, located in the top-level directory of the record/playback source, contains the following targets to build and deploy the application:

  • clean—This target removes the dist and output working directories under the current directory.

  • all—This target cleans, compiles, and jars up the application into a file called com.bea.wlevs.example.recplay_11.1.1.4_0.jar, and places the generated JAR file into a dist directory below the current directory.

  • deploy—This target deploys the JAR file to Oracle Event Processing using the Deployer utility.

    For more information, see "Deployer Command-Line Reference" in the Oracle Fusion Middleware Administrator's Guide for Oracle Event Processing.

2.10.4 Implementation of the Record and Playback Example

The implementation of the signal generation example generally follows "Creating Oracle Event Processing Applications: Typical Steps" in the Oracle Fusion Middleware Developer's Guide for Oracle Event Processing for Eclipse.

Refer to that section for a task-oriented procedure that describes the typical development process.

All the files of the example are located relative to the MIDDLEWARE_HOME\ocep_11.1\samples\source\applications\recplay directory, where MIDDLEWARE_HOME refers to the Middleware home directory you specified when you installed Oracle Event Processing, such as c:\Oracle\Middleware. Oracle recommends that you use this example directory setup in your own environment, although it is obviously not required.

The files used by the record and playback example include:

  • An EPN assembly file that describes each component in the application and how all the components are connected together as shown in Figure 2-78.

    In the example, the file is called com.bea.wlevs.example.recplay-context.xml and is located in the META-INF/spring directory.

  • Java source file for the simpleEventSource adapter.

    In the example, the file is called SimpleEventSource.java and is located in the src/com/bea/wlevs/adapter/example/recplay directory.

    For a detailed description of how to program the adapter Java files in general, see Section 15.1, "Overview of Custom Adapters".

  • Java source file that describes the PlayedBackEvent and SimpleEvent event types. The SimpleEvent event type is the one originally generated by the adapter, but the PlayedBackEvent event type is used for the events that are played back after having been recorded. The PlayedBackEvents look almost exactly the same as SimpleEvent except they have an extra field, the time the event was recorded.

    In the example, the two events are called SimpleEvent.java and PlayedBackEvent.java and are located in the src/com/bea/wlevs/event/example/recplay directory.

    For a detailed description of this file, as well as general information about programming event types, see Section 9.1, "Overview of Oracle Event Processing Event Types".

  • A Java file that implements the recplayEventSink event bean of the application, which is an event sink that receives both realtime events from the simpleEventSource adapter as well as playback events.

    In the example, the file is called RecplayEventSink.java and is located in the src/com/bea/wlevs/example/recplay directory.

    For more information about event sources and sinks, see Section 16.2, "Handling Events with Sources and Sinks".

  • An XML file that configures the simpleEventSource adapter and eventStream channel components. The adapter includes a <record-parameters> element that specifies that the component will record events to the event store; similarly, the channel includes a <playback-parameters> element that specifies that it receives playback events.

    In the example, the file is called config.xml and is located in the META-INF/wlevs directory.

  • A MANIFEST.MF file that describes the contents of the OSGi bundle that will be deployed to Oracle Event Processing.

    In the example, the MANIFEST.MF file is located in the META-INF directory

    For more information about creating this file, as well as a description of creating the OSGi bundle that you deploy to Oracle Event Processing, see Section 23.1, "Overview of Application Assembly and Deployment".

The record/playback example uses a build.xml Ant file to compile, assemble, and deploy the OSGi bundle; see Section 2.10.2, "Building and Deploying the Event Record/Playback Example from the Source Directory" for a description of this build.xml file if you also use Ant in your development environment.