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:
Section 2.1, "Overview of the Samples Provided in the Distribution Kit"
Section 2.2, "Installing the Default ocep_domain and Samples"
Section 2.3, "Using Oracle Event Processing Visualizer With the Samples"
Section 2.6, "Oracle Continuous Query Language (Oracle CQL) Example"
Oracle Event Processing includes the following samples:
HelloWorld: a basic skeleton of a typical Oracle Event Processing application.
Oracle Continuous Query Language (CQL): an example that shows how to use the Oracle Event Processing Visualizer Query Wizard to construct various Oracle CQL queries to process event streams.
Oracle Spatial: an example that 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.
Foreign Exchange (FX): a complete example that includes multiple components.
Signal Generation: an example that simulates market trading and trend detection.
Event record and playback: an example that shows how to configure event record and playback using a persistent event store.
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/
.
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.
The sample HelloWorld domain is located in \MIDDLEWARE_HOME
\ocep_11.1\samples\domains\helloworld_domain
, where MIDDLEWARE_HOME
refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware
.
See Section 2.5.1, "Running the HelloWorld Example from the helloworld Domain" for details.
The sample CQL domain is located in MIDDLEWARE_HOME
\ocep_11.1\samples\domains\cql_domain
.
See Section 2.6.1, "Running the CQL Example" for details.
The sample Oracle Spatial domain is located in MIDDLEWARE_HOME
\ocep_11.1\samples\domains\spatial_domain
.
See Section 2.7.1, "Running the Oracle Spatial Example" for details.
The sample Foreign Exchange domain is located in MIDDLEWARE_HOME
\ocep_11.1\samples\domains\fx_domain
.
See Section 2.8.1, "Running the Foreign Exchange Example" for details.
The sample Signal Generation domain is located in MIDDLEWARE_HOME
\ocep_11.1\samples\domains\signalgeneration_domain
.
See Section 2.9.1, "Running the Signal Generation Example" for details.
The sample Record and Playback domain is located in MIDDLEWARE_HOME
\ocep_11.1\samples\domains\recplay_domain
.
See Section 2.10.1, "Running the Event Record/Playback Example" for details.
The Java and configuration XML source for each sample is provided in a separate source directory that describes a sample development environment.
The HelloWorld source directory is located in MIDDLEWARE_HOME
\ocep_11.1\samples\source\applications\helloworld
, where MIDDLEWARE_HOME
refers to the Middleware directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware
.
See Section 2.5.4, "Implementation of the HelloWorld Example" for details.
The CQL source directory is located in MIDDLEWARE_HOME
\ocep_11.1\\samples\source\applications\cql
.
See Section 2.6.4, "Implementation of the CQL Example" for details.
The Oracle Spatial source directory is located in MIDDLEWARE_HOME
\ocep_11.1\\samples\source\applications\spatial
.
See Section 2.7.4, "Implementation of the Oracle Spatial Example" for details.
The Foreign Exchange source directory is located in MIDDLEWARE_HOME
\ocep_11.1\samples\source\applications\fx
.
See Section 2.8.4, "Implementation of the FX Example" for details.
The Signal Generation source directory is located in MIDDLEWARE_HOME
\ocep_11.1\samples\source\applications\signalgeneration
.
See Section 2.9.4, "Implementation of the Signal Generation Example" for details.
The Record and Playback source directory is located in MIDDLEWARE_HOME
\ocep_11.1\\samples\source\applications\recplay
.
See Section 2.10.4, "Implementation of the Record and Playback Example" for details.
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.
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.
To increase the throughput and latency when running the samples, and Oracle Event Processing applications in general, Oracle recommends the following:
Use the JRockit JDK included in Oracle JRockit Real Time and enable the deterministic garbage collector by passing the -dgc
parameter to the command that starts the Oracle Event Processing instance for the appropriate domain:
prompt> startwlevs.cmd -dgc
By default the deterministic garbage collector is disabled for the samples.
For more information on Oracle JRockit Real Time, see http://www.oracle.com/technology/products/jrockit/jrrt/index.html
.
When running Oracle Event Processing on a computer with a larger amount of memory, you should set the load generator and server heap sizes appropriately for the size of the computer. On computers with sufficient memory, Oracle recommend a heap size of 1 GB for the server and between 512MB - 1GB for the load generator.
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
The example includes the following components:
helloworldAdapter
—Component that generates Hello World messages every second. In a real-world scenario, this component would typically read a stream of data from a source, such as a data feed from a financial institution, and convert it into a stream of events that the event processor can understand. The HelloWorld application also includes a HelloWorldAdapterFactory
that creates instances of HelloWorldAdapter
.
helloworldInputChannel
—Component that streams the events generated by the adapter (in this case Hello World messages) to the event processor.
helloworldProcessor
—Component that simply forwards the messages from the helloworldAdapter
component to the POJO that contains the business logic. In a real-world scenario, this component would typically execute additional and possibly much more processing of the events from the stream, such as selecting a subset of events based on a property value, grouping events, and so on using Oracle CQL.
helloworldOutputChannel
—Component that streams the events processed by the event processor to the POJO that contains the user-defined business logic.
helloworldBean
—POJO component that simply prints out a message every time it receives a batch of messages from the processor via the output channel. In a real-world scenario, this component would contain the business logic of the application, such as running reports on the set of events from the processor, sending appropriate emails or alerts, and so on.
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:
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
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"
Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:
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
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.
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:
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.
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
Set your development environment as described in Section 3.2, "Setting Your Development Environment."
Execute the all
Ant target to compile and create the application JAR file:
prompt> ant all
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.
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.
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.
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
The application contains three separate event paths in its EPN:
Missing events: this event path consists of an adapter orderCVSAdapter
connected to a channel orderChannel
. The orderChannel
is connected to processor orderProcessor
which is connected to channel alertChannel
which is connected to adapter alertOutput
.
This event path is used to detect missing events in a customer order workflow.
For more information on how to construct the query that the cqlProc
processor executes, see Section 2.6.4.1, "Creating the Missing Event Query".
Moving average: this event path consists of channel stockChannel
connected to processor stockProcessor
which is connected to channel movingAvgChannel
which is connected to adapter movingOutput
.
This event path is used to compute a moving average on stock whose volume is greater than 1000.
For more information on how to construct the query that the cqlProc
processor executes, see Section 2.6.4.2, "Creating the Moving Average Query".
Cache: this event path consists of adapter adapter
connected to channel S1
connected to Oracle CQL processor cacheProcessor
connected to channel S2
connected to bean Bean
. There is a cache stockCache
also connected to the Oracle CQL processor cacheProcessor
. There is also a bean Loader
.
This event path is used to access information from a cache in an Oracle CQL query.
Note:
For more information about the various components in the EPN, see the other samples in this book.
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.
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
Set your development environment, as described in Chapter 3, "Setting Your Development Environment"
Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:
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
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.
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"
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.
Run the load generator using the orderData.prop
properties file:
On Windows:
prompt> runloadgen.cmd orderData.prop
On UNIX:
prompt> runloadgen.sh orderData.prop
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"
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.
Run the load generator using the stockData.prop
properties file:
On Windows:
prompt> runloadgen.cmd stockData.prop
On UNIX:
prompt> runloadgen.sh stockData.prop
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.
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:
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.
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
Set your development environment, as described in Section 3.2, "Setting Your Development Environment"
Execute the all
Ant target to compile and create the application JAR file:
prompt> ant all
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.
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."
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.
This section describes how to create the queries that the CQL example uses, including:
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:
However, it is an error if an order is shipped without an approval event as Table 2-2 lists:
You will create and test a query that detects the missing approval event and generates an alert event:
To create the missing event query:
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.
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
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
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.
In the right-hand pane, expand WLEventServerDomain > NonClusteredServer > Applications.
Select the cql node.
The CQL application screen appears as Figure 2-5 shows.
Figure 2-5 CQL Application Screen: General Tab
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
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
Select the Query Wizard tab.
The Query Wizard screen appears as Figure 2-8 shows.
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.
Click the Templates tab.
The Templates tab appears as Figure 2-9 shows.
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.
Double-click the SSource icon.
The SSource configuration screen appears as Figure 2-10 shows.
The source of your query will be the orderChannel
stream.
Configure the SSource as follows:
Select Stream as the Type.
Select orderChannel from the Select a source pull-down menu.
Click Save.
Click Save Query.
Double-click the Pattern icon.
The Pattern configuration screen appears as Figure 2-11 shows.
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.
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:
"PATTERN Condition" in the Oracle Fusion Middleware CQL Language Reference for Oracle Event Processing
"MATCH_RECOGNIZE Condition" in the Oracle Fusion Middleware CQL Language Reference for Oracle Event Processing
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.
Enter Orders in the Alias field.
This assigns an alias (Orders
) for the pattern to simplify its use later in the query.
Click the Define tab.
The Define tab appears as Figure 2-12 shows.
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:
Enter CustOrder in the Object Name field.
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
Click Save.
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
Enter NoApproval in the Object Name field.
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
Click Save.
Click the Plus Sign button.
The condition definition is added to the Object List.
Enter Shipment in the Object Name field.
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'
.
Click Save.
Click the Plus Sign button.
The Define tab appears as Figure 2-17 shows.
Figure 2-17 Pattern Configuration Dialog: Define Tab Complete
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:
"MEASURES Clause" in the Oracle Fusion Middleware CQL Language Reference for Oracle Event Processing
"MATCH_RECOGNIZE Condition" in the Oracle Fusion Middleware CQL Language Reference for Oracle Event Processing
Enter orderid in the Object Name field.
Click the Expression Builder button and configure the Expression Builder as follows (see Figure 2-19):
In the Variables list, double-click CustOrder.orderid.
Click Save.
Click the Plus Sign button.
Enter amount in the Object Name field.
Click the Expression Builder button and configure the Expression Builder as follows (see Figure 2-20):
In the Variables list, double-click CustOrder.amount.
Click Save.
Click the Plus Sign button.
The Measure tab appears as Figure 2-21 shows.
Click Save.
Double-click the Select icon.
The Select configuration screen appears as Figure 2-22 shows.
Figure 2-22 Select Configuration Dialog: Project Tab
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.
Double-click orderid in the Properties list and select orderid from the Select or Input Alias pull-down menu.
Click the Plus Sign button to add the property to the Generated CQL Statement.
Double-click amount in the Properties list and select amount from the Select or Input Alias pull-down menu.
Click the Plus Sign button to add the property to the Generated CQL Statement.
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.
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
Click Save.
Click Save Query.
Double-click the Output icon.
The Output configuration screen appears as Figure 2-24 shows.
Configure the Output as follows:
Select Query.
Enter Tracking as the Query Name.
Click Inject Rule.
The Inject Rule Confirmation dialog appears as Figure 2-25 shows.
Figure 2-25 Inject Rule Confirmation Dialog
Click OK.
The Query Wizard adds the rule to the cqlProc
processor.
Click Save.
Click on the CQL Rules tab.
The CQL Rules tab appears as Figure 2-26 shows.
Click on the Query radio button.
Confirm that your Tracking
query is present.
Figure 2-26 CQL Rules Tab With Tracking Query
To test the missing event query:
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"
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.
Run the load generator using the orderData.prop
properties file:
On Windows:
prompt> runloadgen.cmd orderData.prop
On UNIX:
prompt> runloadgen.sh orderData.prop
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
Click Initialize Client.
Click the Subscribe tab.
Select the orderalert radio button.
Click Subscribe.
As missing events are detected, the Oracle Event Processing updates the Received Messages area showing the AlertEvents
generated.
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:
First, you create a view (the Oracle CQL equivalent of a subquery) that serves as the source of the moving average query.
See "To create a view source for the moving average query:".
Second, you create the moving average query using the source view.
See "To create the moving average query using the view source:".
Finally, you test the moving average query.
To create a view source for the moving average query:
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.
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
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
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.
In the right-hand pane, expand WLEventServerDomain > NonClusteredServer > Applications.
Select the cql node.
The CQL application screen appears as Figure 2-30 shows.
Figure 2-30 CQL Application Screen: General Tab
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
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
Select the Query Wizard tab.
The Query Wizard screen appears as Figure 2-33 shows.
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.
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.
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.
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.
Click Save.
Click Save Query.
When prompted, enter StockVolGt1000 in the Query Id field.
Click Save.
Next, you will add an Oracle CQL filter.
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.
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
Double-click the Filter icon.
The Filter configuration screen appears as Figure 2-38 shows.
Click the Expression Builder button.
The Expression Builder dialog appears.
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.
Click Save.
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
Click Save.
Click Save Query.
Next you want to add a select statement.
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.
Click on the Filter icon and drag to the Select icon to connect the Oracle CQL constructs.
Double-click the Select icon.
The Select configuration screen appears.
You want to select price
, symbol
, and volume
from your StockVolGt1000
stream.
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
Click Save.
Click Save Query.
Finally, you will add an Output.
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.
Click on the Select icon and drag to the Output icon to connect the Oracle CQL constructs.
Double-click the Output icon.
The Output configuration screen appears.
Configure the Output as follows (as shown in Figure 2-44):
Select View.
Configure View Name as StockVolGt1000
.
Delete the contents of the View Schema field.
You can let the Oracle Event Processing server define the view schema for you.
Click Inject Rule.
The Inject Rule Confirmation dialog appears as Figure 2-45 shows.
Figure 2-45 Inject Rule Confirmation Dialog
Click OK.
The Query Wizard adds the rule to the cqlProc
processor.
Click Save.
Click on the CQL Rules tab.
The CQL Rules tab appears as Figure 2-46 shows.
Click on the View radio button.
Confirm that your StockVolGt1000
view is present.
Figure 2-46 CQL Rules Tab With View StockVolGt1000
To create the moving average query using the view source:
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.
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
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
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.
In the left-hand pane, expand WLEventServerDomain > NonClusteredServer > Applications.
Select the cql node.
The CQL application screen appears as Figure 2-49 shows.
Figure 2-49 CQL Application Screen: General Tab
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
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
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
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.
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
Double-click the SSource icon.
The SSource configuration screen appears.
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
Click Save.
Click Save Query.
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
Click on the SSource icon and drag to the Window icon to connect the Oracle CQL constructs.
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
.
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.
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
Click Save.
Click Save Query.
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
Click on the Window icon and drag to the Select icon to connect the Oracle CQL constructs.
Double-click the Select icon.
The Select configuration screen appears.
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:").
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.
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
In this case, you just want to map the source property symbol
to output event property symbol
as is.
Click on the pull-down menu next to the AS field and select symbol.
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
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
In this case, you want to process the source property price
before you map it to the output event.
Click the Expression Builder button.
The Expression Builder dialog appears.
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.
Select the StockVolGt1000.price in the Expression Builder field.
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
Click Save.
The expression is added to the Project Expression field as Figure 2-62 shows.
Figure 2-62 Select Configuration Dialog: With Expression
Click on the pull-down menu next to the AS field and select movingAvgPrice.
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
Click Validate.
A validation error dialog is shown as Figure 2-64 shows.
Because you are partitioning, you must specify a GROUP BY
clause.
Select the Group tab.
The Group tab appears.
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
Click Save.
Click Save Query.
Next, you want to connect the query to an output.
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.
Click on the Select icon and drag to the Output icon to connect the Oracle CQL constructs.
Double-click the Output icon.
The Output configuration screen appears.
Configure the Output as follows (as shown in Figure 2-67):
Select Query.
Enter MovingAverage as the Query Name.
Click Inject Rule.
The Inject Rule Confirmation dialog appears as Figure 2-68 shows.
Figure 2-68 Inject Rule Confirmation Dialog
Click OK.
The Query Wizard adds the rule to the cqlProc
processor.
Click Save.
Click on the CQL Rules tab.
The CQL Rules tab appears as Figure 2-69 shows.
Click on the Query radio button.
Confirm that your MovingAverage
query is present.
Figure 2-69 CQL Rules Tab With View MovingAverage
To test the moving average query:
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."
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.
Run the load generator using the stockData.prop
properties file:
On Windows:
prompt> runloadgen.cmd stockData.prop
On UNIX:
prompt> runloadgen.sh stockData.prop
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
Click Initialize Client.
Enter /stockmoving
in the Initialize client field.
Click Subscribe.
As the moving average query outputs events, the Oracle Event Processing updates the Received Messages area showing the events generated.
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
The example includes the following components:
BusPositionGen
—Component that simulates an input stream of bus position GPS events. It uses the Oracle Event Processing loadgen utility and csvgen adapter provider to read in comma separated values (CSV) and deliver them to the EPN as BusPos
events.
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
.
BusPosStream
—Component that transmits BusPos
events to the Processor
as a stream.
BusStopRelation
—Component that transmits BusPos
events to the Processor
as a relation.
Processor
—Component that executes Oracle CQL queries on the incoming BusPos
events.
BusStopChannel
, BusPosChannel
, and BusStopArrivalChannel
—Components that each specify a different selector to transmit the results of a different query from the Processor
component to the appropriate outbound adapter or output bean.
BusStopPub
, BusPosPub
, and BusStopArrivalPub
—Components that publish the results of the Processor
component's queries.
BusStopArrivalOutputBean
—POJO event bean component that logs a message for each insert, delete, and update event to help visualize the relation offered by the BusStopArrivalChannel
.
Note:
For more information about data cartridges, see:
"Introduction to Data Cartridges" in the Oracle Fusion Middleware CQL Language Reference for Oracle Event Processing
"Oracle Spatial" in the Oracle Fusion Middleware CQL Language Reference for Oracle Event Processing
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:
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
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"
Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:
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
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.
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.
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
Execute the Oracle Event Processing load generator to generate sample data:
On Windows:
Open a command prompt and navigate to MIDDLEWARE_HOME
/ocep_11.1/utils/load-generator
runloadgen.cmd bus_positions.prop
On UNIX:
Open a terminal window and navigate to MIDDLEWARE_HOME
/ocep_11.1/utils/load-generator
runloadgen.sh bus_positions.prop
Observe the bus movements and alerts in the browser as Figure 2-74 shows.
Figure 2-74 Oracle Spatial Web Page: Bus Tracking
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:
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.
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
Set your development environment as described in Section 3.2, "Setting Your Development Environment."
Execute the all
Ant target to compile and create the application JAR file:
prompt> ant all
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.
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.
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.
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
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.
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:
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
Set your development environment, as described in Section 3.2, "Setting Your Development Environment."
Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:
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
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.
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."
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.
Run the load generator using the fxAmer.prop
properties file:
On Windows:
prompt> runloadgen.cmd fxAmer.prop
On UNIX:
prompt> runloadgen.sh fxAmer.prop
Repeat steps 4 - 6 to simulate an Asian data feed, using the fxAsia.prop
properties file:
On Windows:
prompt> runloadgen.cmd fxAsia.prop
On UNIX:
prompt> runloadgen.sh fxAsia.prop
Repeat steps 4 - 6 to simulate an European data feed, using the fxEuro.prop
properties file:
On Windows:
prompt> runloadgen.cmd fxEuro.prop
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.
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:
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.
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
Set your development environment, as described in Section 3.2, "Setting Your Development Environment."
Execute the all
Ant target to compile and create the application JAR file:
prompt> ant all
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.
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.
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.
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.
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
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.
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:
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
Set your development environment, as described in Section 3.2, "Setting Your Development Environment."
Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:
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
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 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.
0pen a new command window.
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
.
Run the startDataFeed
command:
On Windows:
prompt> startDataFeed.cmd
On UNIX:
prompt> startDataFeed.sh
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
.
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.
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:
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.
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
Set your development environment, as described in Section 3.2, "Setting Your Development Environment."
Execute the all
Ant target to compile and create the application JAR file:
prompt> ant all
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.
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."
Invoke the example dashboard as described in Section 2.9.1, "Running the Signal Generation Example."
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.
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.
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
The application contains four components in its event processing network:
simpleEventSource
: an adapter that generates simple events for purposes of the example. This component has been configured to record events, as shown in the graphic.
The configuration source for this adapter is:
<adapter> <name>simpleEventSource</name> <record-parameters> ... </record-parameters> </adapter>
eventStream
: a channel that connects the simpleEventSource
adapter and recplayEventSink
event bean. This component has been configured to playback events.
The configuration source for this channel is:
<channel> <name>eventStream</name> <playback-parameters> ... </playback-parameters> ... </channel>
recplayEventSink
: an event bean that acts as a sink for the events generated by the adapter.
playbackHttpPublisher
: a publishing HTTP pub-sub adapter that listens to the recplayEventSink
event bean and publishes to a channel called /playbackchannel
of the Oracle Event Processing HTTP Pub-Sub server.
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:
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
Set your development environment, as described in Section 3.2, "Setting Your Development Environment."
Start Oracle Event Processing by executing the appropriate script with the correct command line arguments:
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
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.
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
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
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.
In the left pane, select WLEventServerDomain > NonClusteredServer > Applications > recplay > Stages > simpleEventSource.
In the right pane, select the Record tab as shown in Figure 2-81.
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>
At the bottom of the Record tab, click Start.
An Alert dialog appears as shown in Figure 2-82.
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.
In the left pane, select eventStream.
In the right pane, select the Playback tab as shown in Figure 2-83.
At the bottom of the tab, click Start.
An Alert dialog appears as shown in Figure 2-84.
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.
To view the events that the playbackHttpPublisher
adapter is publishing to a channel, follow these steps:
In the top pane, select Viewstream.
The Viewstream window appears as shown in Figure 2-85.
In the right pane, click Initialize Client.
In the Subscribe Channel text box, enter /playbackchannel
.
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.
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:
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.
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
Set your development environment, as described in Section 3.2, "Setting Your Development Environment."
Execute the all
Ant target to compile and create the application JAR file:
prompt> ant all
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.
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.
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.
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.