3 Getting Started with Developing Oracle Event Processing Applications

This chapter provides suggestions for getting started in building Oracle Event Processing applications, including suggested start-to-finish steps, setting up a development environment, and tools for development and testing.

This chapter includes the following sections:

3.1 Creating an Oracle Event Processing Application

The following procedure shows the suggested start-to-finish steps to create an Oracle Event Processing application. Although it is not required to program and configure the various components in the order shown, the procedure shows a typical and logical flow recommended by Oracle.

It is assumed in the procedure that you are using an IDE, although it is not required and the one you use is your choice. For one targeted to Oracle Event Processing developers, see Chapter 4, "Overview of the Oracle Event Processing IDE for Eclipse"

To create an Oracle Event Processing application:

  1. Set up your environment as described in Section 3.2, "Setting Your Development Environment."

  2. Create an Oracle Event Processing project using the Oracle Event Processing IDE for Eclipse.

    For more information, see Chapter 5, "Oracle Event Processing IDE for Eclipse Projects".

  3. Design your event processing network (EPN).

    Using the Oracle Event Processing IDE for Eclipse and the EPN editor, add the full list of components that make up the application and how they are connected to each other, as well as registering the event types used in your application.

    This step combines both designing of your application, in particular determining the components that you need to configure and code, as well as creating the actual XML file that specifies all the components (the EPN assembly file) and the XML file that specifies component configuration (the component configuration file). You will likely be constantly updating these XML files as you implement your application, but Oracle recommends you start with this step so you have a high-level view of your application.

    For more information, see:

  4. Determine the event types that your application is going to use, and, if creating your own JavaBean, program the Java file.

    See Chapter 9, "Defining and Using Event Types"

  5. Program, and optionally configure, the adapters or event beans that act as inbound, intermediate, or outbound components of your event processing network. You can create your own adapters or event beans, or use the adapters provided by Oracle Event Processing. For details, see:

  6. Configure the processors by creating their component configuration XML files; the most important part of this step is designing and declaring the initial rules that are associated with each processor.

    See:

  7. Design the rules that the processors are going to use to select events from their upstream channels and output events to their downstream channels.

    See:

    Note:

    Oracle CQL replaces Event Processing Language (EPL) in Oracle Event Processing 11g Release 1 (11.1.1). Oracle Event Processing supports EPL for backwards compatibility.

  8. Optionally configure the channels that stream data between adapters, processors, and the business logic POJO by creating their configuration XML files.

    See Chapter 10, "Connecting EPN Stages Using Channels."

  9. Optionally configure the caching system to publish or consume events to and from a cache to increase the availability of the events and increase the performance of your applications.

    See Chapter 13, "Integrating a Cache."

  10. Optionally, use the Oracle Event Processing server log subsystem to write log messages from your application to the Oracle Event Processing server log:

    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    ...
    Log LOG=LogFactory.getLog("LogName");
    ...
    LOG.debug("Some debug information");
    ...
    

    Using the Oracle Event Processing Visualizer, you can deploy your application, configure the log level for your application, and view the Oracle Event Processing server console.

    For more information, see:

3.2 Setting Your Development Environment

You must set your development environment before you can start Oracle Event Processing instances and run the samples. In particular, you must set the PATH and JAVA_HOME environment variables so that you are using the correct version of the JRockit JDK.

There are two ways in which JRockit might have been installed on your computer:

  • As part of the Oracle JRockit Real Time installation. This version of the JRockit JDK includes the deterministic garbage collector.

  • As part of the Oracle Event Processing 11g Release 1 (11.1.1) installation. This version of the JRockit JDK does not include the deterministic garbage collector, and is provided for testing purposes only.

Although not required, Oracle recommends that you run Oracle Event Processing using the JRockit JDK version included in Oracle JRockit Real Time for best results; however, the following procedures describe how to set your environment for either case.

For more information about JRockit, see Section 2.4, "Increasing the Performance of the Samples".

This section describes:

3.2.1 How to Set Your Development Environment on Windows

This procedure describes how to set your development environment on Windows.

To make it easier to reset your development environment after logging out of a session, you can create a command file, such as setEnv.cmd, that contains the set commands this section describes.

You can also set the required environment variables permanently on your Windows computer by invoking the Control Panel > System window, clicking the Advanced tab, and then clicking the Environment Variables button. You can set the environment variables for the current user or for the entire system.

To set your development environment on Windows:

  1. Update your PATH environment variable to include the bin directory of the JRockit JDK. Also, be sure that your PATH environment variable includes the bin directory of your Ant installation:

    1. If using the JRockit JDK installed with Oracle JRockit Real Time:

      If you installed Oracle JRockit Real Time in the d:\jrockit directory and Ant is installed in the d:\ant directory, set your PATH environment variable as shown:

      prompt> set PATH=d:\jrockit\[JRRT_HOME]\bin;d:\ant\bin;%PATH%
      

      where JRRT_HOME is the JRockit Real Time directory.

    2. If using the JRockit JDK installed with Oracle Event Processing:

      If you installed Oracle Event Processing in the d:\Oracle\Middleware directory and Ant is installed in the d:\ant directory, set your PATH environment variable as shown:

      prompt> set PATH=d:\Oracle\Middleware\jrockit_160_20\bin;d:\ant\bin;%PATH%
      
  2. Ensure that the JAVA_HOME variable in the setDomainEnv.cmd script points to the correct JRockit JDK. If it does not, edit the script.

    The setDomainEnv.cmd script is located in the defaultserver subdirectory of the main domain directory; the defaultserver subdirectory contains the files for the standalone server of each domain. For example, the HelloWorld domain is located in MIDDLEWARE_HOME\ocep_11.1\samples\domains\helloworld_domain, where MIDDLEWARE_HOME refers to the Middleware home directory you specified when you installed Oracle Event Processing, such as d:\Oracle\Middleware.

    1. If using the JRockit JDK installed with Oracle JRockit Real Time:

      The set command should be as follows:

      set JAVA_HOME=d:\jrockit\[JRRT_HOME]
      

      where JRRT_HOME is the JRockit Real Time directory.

    2. If using the JRockit JDK installed with Oracle Event Processing:

      The set command should be as follows:

      set JAVA_HOME=d:\Oracle\Middleware\jrockit_160_20
      
  3. Set the JAVA_HOME variable in your own development environment to point to the JRockit JDK.

    1. If using the JRockit JDK installed with Oracle JRockit Real Time:

      The set command should be as follows:

      prompt> set JAVA_HOME=d:\jrockit\[JRRT_HOME]
      

      where JRRT_HOME is the JRockit Real Time directory.

    2. If using the JRockit JDK installed with Oracle Event Processing:

      The set command should be as follows:

      prompt> set JAVA_HOME=d:\Oracle\Middleware\jrockit_160_20
      

3.2.2 How to Set Your Development Environment on UNIX

This procedure describes how to set your development environment on UNIX.

To make it easier to reset your development environment after logging out of a session, you can create a command file, such as setEnv.sh, that contains the set commands this section describes.

To set your development environment on UNIX:

  1. Update your PATH environment variable to include the bin directory of the JRockit JDK. Also, be sure that your PATH environment variable includes the bin directory of your Ant installation.

    1. If using the JRockit JDK installed with Oracle JRockit Real Time:

      If you installed Oracle JRockit Real Time in the /jrockit directory and Ant is installed in the /ant directory, set your PATH environment variable as follows:

      prompt> PATH=/jrockit/j[JRRT_HOME]/bin:/ant/bin:$PATH
      

      where JRRT_HOME is the JRockit Real Time directory.

    2. If using the JRockit JDK installed with Oracle Event Processing:

      If you installed Oracle Event Processing in the /Oracle/Middleware directory and Ant is installed in the /ant directory, set your PATH environment variable as shown:

      prompt> PATH=/Oracle/Middleware/jrockit_160_20/bin:/ant/bin:$PATH
      
  2. Ensure that the JAVA_HOME variable in the setDomainEnv.sh script points to the correct JRockit JDK. If it does not, edit the script.

    The setDomainEnv.sh script is located in the defaultserver subdirectory of the main domain directory; the defaultserver subdirectory contains the files for the standalone server of each domain. For example, the HelloWorld domain is located in MIDDLEWARE_HOME/ocep_11.1/samples/domains/helloworld_domain, where MIDDLEWARE_HOME refers to the Middleware home directory you specified when you installed Oracle Event Processing, such as /Oracle/Middleware.

    1. If using the JRockit JDK installed with Oracle JRockit Real Time:

      The JAVA_HOME variable should be set as follows:

      JAVA_HOME=/jrockit/[JRRT_HOME]
      

      where JRRT_HOME is the JRockit Real Time directory.

    2. If using the JRockit JDK installed with Oracle Event Processing:

      The JAVA_HOME variable should be set as follows:

      JAVA_HOME=/Oracle/Middleware/jrockit_160_20
      
  3. Set the JAVA_HOME variable in your development environment to point to the JRockit JDK.

    1. If using the JRockit JDK installed with Oracle JRockit Real Time:

      The JAVA_HOME variable should be set as follows:

      prompt> JAVA_HOME=/jrockit/[JRRT_HOME]
      

      where JRRT_HOME is the JRockit Real Time directory.

    2. If using the JRockit JDK installed with Oracle Event Processing:

      The JAVA_HOME variable should be set as follows:

      prompt> JAVA_HOME=/Oracle/Middleware/jrockit_160_20
      

3.3 Using an IDE to Develop Applications

Oracle Event Processing includes a pluging that enhances the Eclipse IDE with features specifically designed to ease the work of building Oracle Event Processing applications. For more information about the IDE, see Section 4, "Overview of the Oracle Event Processing IDE for Eclipse".

3.4 Testing Applications

You can test Oracle Event Processing applications you build by using the included csvadapter and load generator.

The load generator is a command-line tool the reads a comma-separated values (CSV) file and feeds the results to the csvadapter. The csvadapter, in turn, is designed to receive values from the load generator, then bind those values to an event type that you specify.

Using these tools is a relatively simple way to try out code in development before you are ready for the application to receive data from the actual event data source.

For more information about testing with these tools, see Section 21, "Testing Applications With the Load Generator and csvgen Adapter".