23 Configuring Scalability

This chapter describes how to configure scalability for your Oracle Complex Event Processing (Oracle CEP) application, including information on setting up event partitioning.

For more information on scalability options, see Chapter 22, "Understanding Scalability".

23.1 Configuring Scalability With a Channel EventPartitioner

This section describes how to configure a channel with an Oracle CEP event partitioner as Figure 23-1 shows, including:

Figure 23-1 EventPartitioner EPN

Description of Figure 23-1 follows
Description of "Figure 23-1 EventPartitioner EPN"

In this example, assume that the inbound adapter is sending events of type PriceEvent, defined as Example 23-1 shows:

Example 23-1 Definition of Event Type PriceEvent

<wlevs:event-type-repository>
    <wlevs:event-type type-name="PriceEvent">
        <wlevs:properties>
            <wlevs:property name="symbol" type="char" />
            <wlevs:property name="price" type="long" />
        </wlevs:properties>
    </wlevs:event-type>
</wlevs:event-type-repository>

For more information, see Section 22.2.1, "EventPartitioner".

23.1.1 How to Configure Scalability With the Default Channel EventPartitioner

You can configure a channel to use the default event property-based event partitioner. Each time an incoming event arrives, the channel selects a listener and dispatches the event to that listener instead of broadcasting each event to every listener.

Optionally, you can implement your own EventPartitioner class to customize how the channel dispatches events to its listeners as Section 23.1.2, "How to Configure Scalability With a Custom Channel EventPartitioner" describes.

To configure scalability with the default channel EventPartitioner:

  1. Add a channel to your EPN.

    In Figure 23-1, the channel is EventPartitionerChannel.

    For more information, see Chapter 9, "Configuring Channels".

  2. Connect the channel to an upstream adapter.

    In Figure 23-1, the upstream adapter is inbound.

    For more information, see Section 6.4.2, "Connecting Nodes".

  3. Connect the channel to two or more listeners.

    In Figure 23-1, the channel is connected to Oracle CQL processors processor1, processor2, and processor3.

    For more information, see Section 6.4.2, "Connecting Nodes"

  4. Edit the EPN assembly file to add a partitionByEventProperty instance property to the channel element.

    The value of this instance-property is the name of the event property by which the channel partitions events.

    In this example, the channel partitions events by event property symbol.

    
    ...
        <wlevs:channel id="EventPartitionerChannel" event-type="PriceEvent">
            <wlevs:instance-property name="partitionByEventProperty" value="symbol" />
            <wlevs:listener ref="processor1" />
            <wlevs:listener ref="processor2" />
            <wlevs:listener ref="processor3" />
            <wlevs:source ref="inbound" />
        </wlevs:channel>
    ...
    

    For more information, see Section 22.2.1.1, "EventPartitioner Implementation".

  5. Decide how you want Oracle CEP to allocate threads as Section 22.2.1.3, "EventPartitioner Threading" describes:

    1. If you want the channel to allocate threads:

      • Edit the EPN assembly file to configure the channel to set max-threads to the number of listeners.

        
        ...
            <wlevs:channel id="EventPartitionerChannel" event-type="PriceEvent"        max-threads="3" >
                <wlevs:instance-property name="eventPartitioner" value="true" />
                <wlevs:listener ref="processor1" />
                <wlevs:listener ref="processor2" />
                <wlevs:listener ref="processor3" />
                <wlevs:source ref="inbound" />
            </wlevs:channel>
        ...
        
    2. If you want the upstream adapter to allocate threads:

      • Edit the EPN assembly file to configure the channel to set max-threads to 0.

        
        ...
            <wlevs:channel id="EventPartitionerChannel" event-type="PriceEvent"         max-threads="0" >
                <wlevs:instance-property name="eventPartitioner" value="true" />
                <wlevs:listener ref="processor1" />
                <wlevs:listener ref="processor2" />
                <wlevs:listener ref="processor3" />
                <wlevs:source ref="inbound" />
            </wlevs:channel>
        ...
        
      • Edit the Oracle CEP server config.xml file to add a work-manager element.

        If this work manager is shared by more than one component (such as other adapters and Jetty), then set the min-threads-constraint and max-threads-constraint elements each to a value greater than the number of listeners.

        If this work manager is not shared by more than one component (that is, it is dedicated to the upstream adapter in this configuration), then set the min-threads-constraint and max-threads-constraint elements equal to the number of listeners.

        ...
        <work-manager>
            <name>adapterWorkManager</name>
            <min-threads-constraint>3</min-threads-constraint>
            <max-threads-constraint>3</max-threads-constraint>
        </work-manager>
        ...
        

        For more information, see Section F.45, "work-manager".

      • Edit the component configuration file to configure the upstream adapter with this work-manager.

        
        ...
        <adapter>
            <name>inbound</name>
            <work-manager-name>adapterWorkManager</work-manager-name>
            ...
        </adapter>
        ...
        
  6. Assemble and deploy your application.

    For more information, see Chapter 24, "Assembling and Deploying Oracle CEP Applications".

    At runtime, the channel uses the default event property-based EventPartitioner to determine how to dispatch each incoming event to its listeners.

23.1.2 How to Configure Scalability With a Custom Channel EventPartitioner

You can implement your own EventPartitioner class to customize how a channel dispatches events to its listeners.

Optionally, you can use the default event property-based EventPartitioner as Section 23.1.1, "How to Configure Scalability With the Default Channel EventPartitioner" describes.

To configure scalability with a custom channel EventPartitioner:

  1. Using the Oracle CEP IDE for Eclipse, open your Oracle CEP project.

    For more information, see Section 4.2, "Creating Oracle CEP Projects".

  2. Edit your MANIFEST.MF to import package com.bea.wlevs.channel.

    For more information, see Section 4.7.5, "How to Import a Package".

  3. Right-click your project's src folder and select New > Class.

    The New Java Class dialog appears as Figure 23-2 shows.

    Figure 23-2 New Java Class Dialog

    Description of Figure 23-2 follows
    Description of "Figure 23-2 New Java Class Dialog"

  4. Configure the New Java Class dialog as Table 23-1 describes.

    Table 23-1 New Java Class Options for EventPartitioner

    Option Description

    Package

    Enter the class's package name.

    Name

    Enter the class's name.

    Interfaces

    Click Add and use the Implemented Interfaces Selection dialog to locate the com.bea.wlevs.channel.EventPartitioner interface, select it in the Matching Items list, and then click OK.


  5. Click Finish.

    A new EventPartitioner class is created as Example 23-2 shows.

    Example 23-2 EventPartitioner Class

    package com.acme;
    
    import com.bea.wlevs.channel.EventPartitioner;
    import com.bea.wlevs.ede.api.EventProcessingException;
    import com.bea.wlevs.ede.api.EventType;
    
    public class MyEventPartitioner implements EventPartitioner {
    
        @Override
        public void activateConfiguration(int arg0, EventType arg1) {
            // TODO Auto-generated method stub
    
        }
    
        @Override
        public int partition(Object arg0) throws EventProcessingException {
            // TODO Auto-generated method stub
            return 0;
        }
     
    }
    
  6. Complete the implementation of your EventPartitioner as Example 23-3 shows.

    Example 23-3 EventPartitioner Class Implementation

    package com.acme;
    
    import com.bea.wlevs.channel.EventPartitioner;
    import com.bea.wlevs.ede.api.EventProcessingException;
    import com.bea.wlevs.ede.api.EventType;
    
    public class MyEventPartitioner implements EventPartitioner {
    
        private final EventType eventType;
        private int numberOfPartitions;
    
        @Override
        public void activateConfiguration(int numberOfPartitions, EventType eventType) {
            this.numberOfPartitions = numberOfPartitions;
            this.eventType = eventType;
        }
    
        @Override
        public int partition(Object event) throws EventProcessingException {
            int dispatchToListener = 0;
            ... // Your implementation.
            return dispatchToListener;
        }
    
    }
    

    The activateConfiguration method is a callback that the Oracle CEP server invokes before ActivatableBean.afterConfigurationActive and before your EventPartitioner class's partition method is invoked.

    When you associate this EventPartitioner with a channel, the channel will invoke your EventPartitioner class's partition method each time the channel receives an event.

    Your partition method must return the index of the listener to which the channel should dispatch the event. The index must be an int between 0 and numberOfPartitions - 1.

  7. Add a channel to your EPN.

    In Figure 23-1, the channel is EventPartitionerChannel.

    For more information, see Chapter 9, "Configuring Channels".

  8. Connect the channel to an upstream adapter.

    In Figure 23-1, the upstream adapter is inbound.

    For more information, see Section 6.4.2, "Connecting Nodes".

  9. Connect the channel to two or more listeners.

    In Figure 23-1, the channel is connected to Oracle CQL processors processor1, processor2, and processor3.

    If you want to the channel to perform load balancing, each listener must be identical.

    For more information, see:

  10. Edit the EPN assembly file to add an eventPartitioner instance property to the channel element.

    The value of this instance-property is the fully qualified class name of the EventPartitioner instance the channel will use to partition events.

    This class must be on your Oracle CEP application class path.

    In this example, the channel uses EventPartitioner instance com.acme.MyEventPartitioner to partition events.

    ...
        <wlevs:channel id="EventPartitionerChannel" event-type="PriceEvent" max-threads="0" >
            <wlevs:instance-property name="eventPartitioner"             value="com.acme.MyEventPartitioner" />
            <wlevs:listener ref="filterFanoutProcessor1" />
            <wlevs:listener ref="filterFanoutProcessor2" />
            <wlevs:listener ref="filterFanoutProcessor3" />
            <wlevs:source ref="PriceAdapter" />
        </wlevs:channel>
    ...
    
  11. Decide how you want Oracle CEP to allocate threads as Section 22.2.1.3, "EventPartitioner Threading" describes:

    1. If you want the channel to allocate threads:

      • Edit the EPN assembly file to configure the channel to set max-threads to the number of listeners.

        ...
            <wlevs:channel id="EventPartitionerChannel" event-type="PriceEvent"         max-threads="3" >
                <wlevs:instance-property name="eventPartitioner" value="true" />
                <wlevs:listener ref="processor1" />
                <wlevs:listener ref="processor2" />
                <wlevs:listener ref="processor3" />
                <wlevs:source ref="inbound" />
            </wlevs:channel>
        ...
        
    2. If you want the upstream adapter to allocate threads:

      • Edit the EPN assembly file to configure the channel to set max-threads to 0.

        ...
            <wlevs:channel id="EventPartitionerChannel" event-type="PriceEvent"         max-threads="0" >
                <wlevs:instance-property name="eventPartitioner" value="true" />
                <wlevs:listener ref="processor1" />
                <wlevs:listener ref="processor2" />
                <wlevs:listener ref="processor3" />
                <wlevs:source ref="inbound" />
            </wlevs:channel>
        ...
        
      • Edit the Oracle CEP server config.xml file to add a work-manager element.

        If this work manager is shared by more than one component (such as other adapters and Jetty), then set the min-threads-constraint and max-threads-constraint elements each to a value greater than the number of listeners.

        If this work manager is not shared by more than one component (that is, it is dedicated to the upstream adapter in this configuration), then set the min-threads-constraint and max-threads-constraint elements equal to the number of listeners.

        ...
        <work-manager>
            <name>adapterWorkManager</name>
            <min-threads-constraint>3</min-threads-constraint>
            <max-threads-constraint>3</max-threads-constraint>
        </work-manager>
        ...
        

        For more information, see Section F.45, "work-manager".

      • Edit the component configuration file to configure the upstream adapter with this work-manager.

        ...
        <adapter>
            <name>inbound</name>
            <work-manager-name>adapterWorkManager</work-manager-name>
            ...
        </adapter>
        ...
        
  12. Assemble and deploy your application.

    For more information, see Chapter 24, "Assembling and Deploying Oracle CEP Applications".

    At runtime, the channel uses your EventPartitioner to determine how to dispatch each incoming event to its listeners.

23.2 Configuring Scalability With the ActiveActiveGroupBean

This section describes how to configure your Oracle CEP application to use the ActiveActiveGroupBean to partition an incoming JMS event stream by selector, including:

For more information, see Section 22.2.2, "ActiveActiveGroupBean".

23.2.1 How to Configure Scalability in a JMS Application Without Oracle CEP High Availability

You can use the ActiveActiveGroupBean to partition an incoming JMS event stream by selector in a multi-server domain for an application that does not use Oracle CEP high availability.

For information on how to use the ActiveActiveGroupBean in an Oracle CEP high availability application, see Section 23.2.2, "How to Configure Scalability in a JMS Application With Oracle CEP High Availability".

For more information, see Section 22.2.2.1, "Scalability in an Oracle CEP Application Using the ActiveActiveGroupBean Without High Availability".

To configure scalability in a JMS application without Oracle CEP high availability:

  1. Create a multi-server domain.

    For more information, see "Introduction to Multi-Server Domains" in the Oracle Fusion Middleware Administrator's Guide for Oracle Complex Event Processing.

    In this example, the deployment group is named MyDeploymentGroup.

  2. Configure the Oracle CEP server configuration file on each Oracle CEP server to add the appropriate ActiveActiveGroupBean notification group to the groups child element of the cluster element.

    The Oracle CEP server configuration file, config.xml, is located in the DOMAIN_DIR/servername/config directory, where DOMAIN_DIR refers to the main domain directory and servername refers to a particular server instance.

    For example, Table 23-3 shows cluster elements for Oracle CEP servers ocep-server-1, ocep-server-2, ocep-server-3, and ocep-server-4. The deployment group is MyDeploymentGroup and notification groups are defined using default ActiveActiveGroupBean notification group naming.

    Optionally, you can specify your own group naming convention as Section 23.2.3, "How to Configure the ActiveActiveGroupBean Group Pattern Match" describes.

    Table 23-2 Oracle CEP Server Configuration File groups Element Configuration

    Partition cluster Element

    ocep-server-1

    <cluster>
        <server-name>ocep-server-1</server-name>
        ...
        <enabled>coherence</enabled>
        ...
        <groups>MyDeploymentGroup, ActiveActiveGroupBean_group1</groups>
    </cluster>
    

    ocep-server-2

    <cluster>
        <server-name>ocep-server-2</server-name>
        ...
        <enabled>coherence</enabled>
        ...
        <groups>MyDeploymentGroup, ActiveActiveGroupBean_group2</groups>
    </cluster>
    

    ocep-server-3

    <cluster>
        <server-name>ocep-server-3</server-name>
        ...
        <enabled>coherence</enabled>
        ...
        <groups>MyDeploymentGroup, ActiveActiveGroupBean_group3</groups>
    </cluster>
    

    ocep-server-4

    <cluster>
        <server-name>ocep-server-4</server-name>
        ...
        <enabled>coherence</enabled>
        ...
        <groups>MyDeploymentGroup, ActiveActiveGroupBean_group4</groups>
    </cluster>
    

  3. Create an Oracle CEP application.

  4. Configure the EPN assembly file to add an ActiveActiveGroupBean element as Example 23-8 shows.

    Example 23-4 ActiveActiveGroupBean bean Element

    <bean id="clusterAdapter" class="com.oracle.cep.cluster.hagroups.ActiveActiveGroupBean">
    </bean>
    
  5. Define a parameterized message-selector in the jms-adapter element for the JMS inbound adapters.

    Edit the component configuration file to add group-binding child elements to the jms-adapter element for the JMS inbound adapters.

    Add one group-binding element for each possible JMS message-selector value as Example 23-10 shows.

    Example 23-5 jms-adapter Selector Definition for ocep-server-1

    <jms-adapter>
        <name>JMSInboundAdapter</name>
        <event-type>StockTick</event-type>
        <jndi-provider-url>t3://ppurich-pc:7001</jndi-provider-url>
        <destination-jndi-name>./Topic1</destination-jndi-name>
        <user>weblogic</user>
        <password>weblogic1</password>
        <work-manager>JettyWorkManager</work-manager>
        <concurrent-consumers>1</concurrent-consumers>
        <session-transacted>true</session-transacted>
        <message-selector>${CONDITION}</message-selector>
        <bindings>
            <group-binding group-id="ActiveActiveGroupBean_group1">
                <param id="CONDITION">acctid > 400</param>
            </group-binding>
            <group-binding group-id="ActiveActiveGroupBean_group2">
                <param id="CONDITION">acctid BETWEEN 301 AND 400</param>
            </group-binding>
            <group-binding group-id="ActiveActiveGroupBean_group3">
                <param id="CONDITION">acctid BETWEEN 201 AND 300</param>
            </group-binding>
            <group-binding group-id="ActiveActiveGroupBean_group4">
                <param id="CONDITION">acctid <= 200</param>
            </group-binding>
         </bindings>
    </jms-adapter>
    

    In this configuration, when the application is deployed to an Oracle CEP server with a cluster element groups child element that contains ActiveActiveGroupBean_group1, then the CONDITION parameter is defined as acctid > 400 and the application processes events whose acctid property is greater than 400.

    Note:

    Each in-bound JMS adapter must listen to a different topic.

    For more information, see Chapter 7, "Configuring JMS Adapters".

  6. Deploy your application to the deployment group of your multi-server domain.

    For more information, see Chapter 24, "Assembling and Deploying Oracle CEP Applications".

    At runtime, each Oracle CEP server configures its instance of the application with the message-selector that corresponds to its ActiveActiveGroupBean notification group. This partitions the JMS topic so that each instance of the application processes a subset of the total number of messages in parallel.

23.2.2 How to Configure Scalability in a JMS Application With Oracle CEP High Availability

You can use the ActiveActiveGroupBean to partition an incoming JMS event stream in a multi-server domain with Oracle CEP high availability.

This procedure uses the example application from Section 21.1.4, "How to Configure Precise Recovery With JMS", including the example EPN that Figure 23-3 shows, the corresponding EPN assembly file that Example 23-6 shows, and the corresponding component configuration file that Example 23-7 shows.

Figure 23-3 Precise Recovery With JMS EPN

Description of Figure 23-3 follows
Description of "Figure 23-3 Precise Recovery With JMS EPN"

Example 23-6 Precise Recovery With JMS EPN Assembly File

<?xml version="1.0" encoding="UTF-8"?>
<beans ... >

    <wlevs:event-type-repository>
        <wlevs:event-type type-name="StockTick">
            <wlevs:properties>
                <wlevs:property name="lastPrice" type="double" />
                <wlevs:property name="symbol" type="char" />
            </wlevs:properties>
        </wlevs:event-type>
    </wlevs:event-type-repository>

    <wlevs:adapter id="JMSInboundAdapter" provider="jms-inbound">
        <wlevs:listener ref="myHaInputAdapter"/>
    </wlevs:adapter>

    <wlevs:adapter id="myHaInputAdapter" provider="ha-inbound" >
        <wlevs:instance-property name="keyProperties" value="sequenceNo"/>
        <wlevs:instance-property name="timeProperty" value="inboundTime"/>
    </wlevs:adapter>

    <wlevs:channel id="channel1" event-type="StockTick">
        <wlevs:listener ref="processor1" />
        <wlevs:source ref="myHaInputAdapter"/>
        <wlevs:application-timestamped>
            <wlevs:expression>inboundTime</wlevs:expression>
        </wlevs:application-timestamped>
    </wlevs:channel>

    <wlevs:processor id="processor1">
        <wlevs:listener ref="channel2" />
    </wlevs:processor>

    <wlevs:channel id="channel2" event-type="StockTick">
        <wlevs:listener ref="myHaCorrelatingAdapter" />
    </wlevs:channel>

    <wlevs:adapter id="myHaCorrelatingAdapter" provider="ha-correlating" >
        <wlevs:instance-property name="correlatedSource" ref="clusterCorrelatingOutstream"/> 
        <wlevs:instance-property name="failOverDelay" value="2000"/> 
        <wlevs:listener ref="JMSOutboundAdapter"/>
    </wlevs:adapter>

    <wlevs:adapter id="JMSOutboundAdapter" provider="jms-outbound">
    </wlevs:adapter>

    <wlevs:adapter id="JMSInboundAdapter2" provider="jms-inbound">
    </wlevs:adapter>

    <wlevs:channel id="clusterCorrelatingOutstream" event-type="StockTick" advertise="true">
        <wlevs:source ref="JMSInboundAdapter2"/>
    </wlevs:channel> 
</beans>

Example 23-7 Precise Recovery With JMS Component Configuration Assembly File

<?xml version="1.0" encoding="UTF-8"?>
<wlevs:config 
        xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application"
        xmlns:ha="http://www.oracle.com/ns/cep/config/cluster/">
    <processor>
        <name>processor1</name>
        <rules>
            <query id="helloworldRule">
                <![CDATA[ select * from channel1 [Now] ]]>
            </query>
        </rules>
    </processor>
    <jms-adapter>
        <name>JMSInboundAdapter</name>
        <event-type>StockTick</event-type>
        <jndi-provider-url>t3://ppurich-pc:7001</jndi-provider-url>
        <destination-jndi-name>./Topic1</destination-jndi-name>
        <session-transacted>true</session-transacted>
    ...
    </jms-adapter>
    <jms-adapter>
        <name>JMSInboundAdapter2</name>
        <event-type>StockTick</event-type>
        <jndi-provider-url>t3://ppurich-pc:7001</jndi-provider-url>
        <destination-jndi-name>./Topic2</destination-jndi-name>
        <session-transacted>true</session-transacted>
    ...
    </jms-adapter>
    <jms-adapter>
        <name>JMSOutboundAdapter</name>
        <event-type>StockTick</event-type>
        <jndi-provider-url>t3://ppurich-pc:7001</jndi-provider-url>
        <destination-jndi-name>./Topic2</destination-jndi-name>
        <session-transacted>true</session-transacted>
    ...
    </jms-adapter>
</wlevs:config>

This procedure will create the Oracle CEP high availability configuration that Figure 23-4 shows.

Figure 23-4 Oracle CEP ActiveActiveGroupBean With High Availability

Description of Figure 23-4 follows
Description of "Figure 23-4 Oracle CEP ActiveActiveGroupBean With High Availability"

For more information, see Section 22.2.2.2, "Scalability in an Oracle CEP Application Using the ActiveActiveGroupBean With High Availability".

To configure scalability in a JMS application with Oracle CEP high availability:

  1. Create a multi-server domain.

    For more information, see "Introduction to Multi-Server Domains" in the Oracle Fusion Middleware Administrator's Guide for Oracle Complex Event Processing.

    In this example, the deployment group is named MyDeploymentGroup.

  2. Configure the Oracle CEP server configuration file on each Oracle CEP server to add the appropriate ActiveActiveGroupBean notification group to the groups child element of the cluster element.

    The Oracle CEP server configuration file, config.xml, is located in the DOMAIN_DIR/servername/config directory, where DOMAIN_DIR refers to the main domain directory and servername refers to a particular server instance.

    For example, Table 23-3 shows cluster elements for Oracle CEP servers ocep-server-1, ocep-server-2, ocep-server-3, and ocep-server-4. The deployment group is MyDeploymentGroup and notification groups are defined using default ActiveActiveGroupBean notification group names.

    Note that ocep-server-1 and ocep-server-2 use the same notification group name (ActiveActiveGroupBean_group1) and ocep-server-3 and ocep-server-4 use the same notification group name (ActiveActiveGroupBean_group2).

    Optionally, you can specify your own group naming convention as Section 23.2.3, "How to Configure the ActiveActiveGroupBean Group Pattern Match" describes.

    Table 23-3 Oracle CEP Server Configuration File groups Element Configuration

    Partition cluster Element

    ocep-server-1

    <cluster>
        <server-name>ocep-server-1</server-name>
        ...
        <enabled>coherence</enabled>
        ...
        <groups>MyDeploymentGroup, ActiveActiveGroupBean_group1</groups>
    </cluster>
    

    ocep-server-2

    <cluster>
        <server-name>ocep-server-2</server-name>
        ...
        <enabled>coherence</enabled>
        ...
        <groups>MyDeploymentGroup, ActiveActiveGroupBean_group1</groups>
    </cluster>
    

    ocep-server-3

    <cluster>
        <server-name>ocep-server-3</server-name>
        ...
        <enabled>coherence</enabled>
        ...
        <groups>MyDeploymentGroup, ActiveActiveGroupBean_group2</groups>
    </cluster>
    

    ocep-server-4

    <cluster>
        <server-name>ocep-server-4</server-name>
        ...
        <enabled>coherence</enabled>
        ...
        <groups>MyDeploymentGroup, ActiveActiveGroupBean_group2</groups>
    </cluster>
    

  3. Create an Oracle CEP high availability application.

    For more information, see Chapter 21, "Configuring High Availability".

  4. Configure the EPN assembly file to add an ActiveActiveGroupBean element as Example 23-8 shows.

    Example 23-8 ActiveActiveGroupBean bean Element

    <bean id="clusterAdapter" class="com.oracle.cep.cluster.hagroups.ActiveActiveGroupBean">
    </bean>
    
  5. Edit the component configuration file to configure a jms-adapter element for the inbound JMS adapters as Example 23-9 shows:

    • Each in-bound JMS adapter must listen to a different topic.

    • Set session-transacted to true.

    Example 23-9 jms-adapter Element for Inbound JMS Adapters

    <?xml version="1.0" encoding="UTF-8"?>
    <wlevs:config 
            xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application"
            xmlns:ha="http://www.oracle.com/ns/cep/config/cluster/">
        ...
        <jms-adapter>
            <name>JMSInboundAdapter</name>
            <event-type>StockTick</event-type>
            <jndi-provider-url>t3://ppurich-pc:7001</jndi-provider-url>
            <destination-jndi-name>./Topic1</destination-jndi-name>
            <session-transacted>true</session-transacted>
        ...    </jms-adapter>
        <jms-adapter>
            <name>JMSInboundAdapter2</name>
            <event-type>StockTick</event-type>
            <jndi-provider-url>t3://ppurich-pc:7001</jndi-provider-url>
            <destination-jndi-name>./Topic2</destination-jndi-name>
            <session-transacted>true</session-transacted>
        ...    </jms-adapter>
    </wlevs:config>
    

    For more information, see Chapter 7, "Configuring JMS Adapters".

  6. Define a parameterized message-selector in the jms-adapter element for each JMS inbound adapter.

    Edit the component configuration file to add group-binding child elements to the jms-adapter element for the JMS inbound adapters.

    Add one group-binding element for each possible JMS message-selector value as Example 23-10 shows.

    Example 23-10 jms-adapter Selector Definition for ocep-server-1

    <jms-adapter>
        <name>JMSInboundAdapter</name>
        <event-type>StockTick</event-type>
        <jndi-provider-url>t3://ppurich-pc:7001</jndi-provider-url>
        <destination-jndi-name>./Topic1</destination-jndi-name>
        <session-transacted>true</session-transacted>
        <message-selector>${CONDITION}</message-selector>
        <bindings>
            <group-binding group-id="ActiveActiveGroupBean_group1">
                <param id="CONDITION">acctid <= 1000</param>
            </group-binding>
            <group-binding group-id="ActiveActiveGroupBean_group2">
                <param id="CONDITION">acctid > 1000</param>
            </group-binding>
         </bindings>
    </jms-adapter>
    

    In this configuration, when the application is deployed to an Oracle CEP server with a cluster element groups child element that contains ActiveActiveGroupBean_group1, then the CONDITION parameter is defined as acctid <= 1000 and the application processes events whose acctid property is less than or equal to 1000. Similarly, when the application is deployed to an Oracle CEP server with a cluster element groups child element that contains ActiveActiveGroupBean_group2, then the CONDITION parameter is defined as acctid > 1000 and the application processes events whose acctid property is greater than 1000.

  7. Edit the component configuration file to configure a jms-adapter element for the outbound JMS adapter as Example 23-11 shows:

    • Configure the out-bound JMS adapter with the same topic as the correlating in-bound adapter (in this example, JMSInboundAdapter2: ./Topic2).

    • Set session-transacted to true.

    Example 23-11 jms-adapter Element for Outbound JMS Adapters

    <?xml version="1.0" encoding="UTF-8"?>
    <wlevs:config 
            xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application"
            xmlns:ha="http://www.oracle.com/ns/cep/config/cluster/">
        ...
        <jms-adapter>
            <name>JMSInboundAdapter</name>
            <event-type>StockTick</event-type>
            <jndi-provider-url>t3://ppurich-pc:7001</jndi-provider-url>
            <destination-jndi-name>./Topic1</destination-jndi-name>
            <session-transacted>true</session-transacted>
        ...    </jms-adapter>
        <jms-adapter>
            <name>JMSInboundAdapter2</name>
            <event-type>StockTick</event-type>
            <jndi-provider-url>t3://ppurich-pc:7001</jndi-provider-url>
            <destination-jndi-name>./Topic2</destination-jndi-name>
            <session-transacted>true</session-transacted>
        ...    </jms-adapter>
        <jms-adapter>
            <name>JMSOutboundAdapter</name>
            <event-type>StockTick</event-type>
            <jndi-provider-url>t3://ppurich-pc:7001</jndi-provider-url>
            <destination-jndi-name>./Topic2</destination-jndi-name>
            <session-transacted>true</session-transacted>
        ...    </jms-adapter>
    </wlevs:config>
    

    For more information, see Chapter 7, "Configuring JMS Adapters".

  8. Deploy your application to the deployment group of your multi-server domain.

    For more information, see Chapter 24, "Assembling and Deploying Oracle CEP Applications".

    At runtime, each Oracle CEP server configures its instance of the application with the message-selector that corresponds to its ActiveActiveGroupBean notification group. This partitions the JMS topic so that each instance of the application processes a subset of the total number of messages in parallel.

    If the active Oracle CEP server in an ActiveActiveGroupBean group goes down, the Oracle CEP server performs an Oracle CEP high availability failover to the standby Oracle CEP server in that ActiveActiveGroupBean group.

23.2.3 How to Configure the ActiveActiveGroupBean Group Pattern Match

By default, the ActiveActiveGroupBean creates notification groups named:

ActiveActiveGroupBean_X

Where X is a string.

At runtime, the ActiveActiveGroupBean scans the existing groups defined on the Oracle CEP server and applies a default pattern match of:

ActiveActiveGroupBean_\\w+

When it finds a match, it creates a notification group of that name.

Optionally, you can define your own group pattern to specify a different notification group naming pattern.

How to configure the ActiveActiveGroupBean group pattern match:

  1. Configure the EPN assembly file to add a groupPattern attribute to your ActiveActiveGroupBean element as Example 23-12 shows.

    Example 23-12 ActiveActiveGroupBean bean Element With groupPattern Attribute

    <bean id="clusterAdapter" class="com.oracle.cep.cluster.hagroups.ActiveActiveGroupBean">
        <property name="groupPattern" value="MyNotificationGroupPattern*"/>
    </bean>
    
  2. Specify a value for the groupPattern attribute that matches the cluster group naming convention you want to use for notification groups.