How to Configure Scalability With a Custom Channel EventPartitioner

23-10 Oracle Complex Event Processing Developers Guide 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 nameJMSInboundAdaptername event-typeStockTickevent-type jndi-provider-urlt3:ppurich-pc:7001jndi-provider-url destination-jndi-name.Topic1destination-jndi-name userweblogicuser passwordweblogic1password work-managerJettyWorkManagerwork-manager concurrent-consumers1concurrent-consumers session-transactedtruesession-transacted message-selector{CONDITION}message-selector bindings group-binding group-id=ActiveActiveGroupBean_group1 param id=CONDITIONacctid 400param group-binding group-binding group-id=ActiveActiveGroupBean_group2 param id=CONDITIONacctid BETWEEN 301 AND 400param group-binding group-binding group-id=ActiveActiveGroupBean_group3 param id=CONDITIONacctid BETWEEN 201 AND 300param group-binding group-binding group-id=ActiveActiveGroupBean_group4 param id=CONDITIONacctid = 200param group-binding bindings ocep-server-3 cluster server-nameocep-server-3server-name ... enabledcoherenceenabled ... groupsMyDeploymentGroup, ActiveActiveGroupBean_group3groups cluster ocep-server-4 cluster server-nameocep-server-4server-name ... enabledcoherenceenabled ... groupsMyDeploymentGroup, ActiveActiveGroupBean_group4groups cluster Table 23–2 Cont. Oracle CEP Server Configuration File groups Element Configuration Partition cluster Element Configuring Scalability 23-11 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. 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 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 Note: Each in-bound JMS adapter must listen to a different topic. For more information, see Chapter 7, Configuring JMS Adapters . 23-12 Oracle Complex Event Processing Developers Guide 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:expressioninboundTimewlevs: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.comnswlevsconfigapplication xmlns:ha=http:www.oracle.comnscepconfigcluster processor nameprocessor1name rules query id=helloworldRule [CDATA[ select from channel1 [Now] ]] query rules processor jms-adapter nameJMSInboundAdaptername event-typeStockTickevent-type jndi-provider-urlt3:ppurich-pc:7001jndi-provider-url destination-jndi-name.Topic1destination-jndi-name session-transactedtruesession-transacted ... jms-adapter jms-adapter nameJMSInboundAdapter2name event-typeStockTickevent-type jndi-provider-urlt3:ppurich-pc:7001jndi-provider-url destination-jndi-name.Topic2destination-jndi-name Configuring Scalability 23-13 session-transactedtruesession-transacted ... jms-adapter jms-adapter nameJMSOutboundAdaptername event-typeStockTickevent-type jndi-provider-urlt3:ppurich-pc:7001jndi-provider-url destination-jndi-name.Topic2destination-jndi-name session-transactedtruesession-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 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 Complex Event Processing Administrators Guide. In this example, the deployment group is named MyDeploymentGroup. 23-14 Oracle Complex Event Processing Developers Guide 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 servernameconfig 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. 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. Table 23–3 Oracle CEP Server Configuration File groups Element Configuration Partition cluster Element ocep-server-1 cluster server-nameocep-server-1server-name ... enabledcoherenceenabled ... groupsMyDeploymentGroup, ActiveActiveGroupBean_group1groups cluster ocep-server-2 cluster server-nameocep-server-2server-name ... enabledcoherenceenabled ... groupsMyDeploymentGroup, ActiveActiveGroupBean_group1groups cluster ocep-server-3 cluster server-nameocep-server-3server-name ... enabledcoherenceenabled ... groupsMyDeploymentGroup, ActiveActiveGroupBean_group2groups cluster ocep-server-4 cluster server-nameocep-server-4server-name ... enabledcoherenceenabled ... groupsMyDeploymentGroup, ActiveActiveGroupBean_group2groups cluster Configuring Scalability 23-15 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.comnswlevsconfigapplication xmlns:ha=http:www.oracle.comnscepconfigcluster ... jms-adapter nameJMSInboundAdaptername event-typeStockTickevent-type jndi-provider-urlt3:ppurich-pc:7001jndi-provider-url destination-jndi-name.Topic1destination-jndi-name session-transactedtruesession-transacted ... jms-adapter jms-adapter nameJMSInboundAdapter2name event-typeStockTickevent-type jndi-provider-urlt3:ppurich-pc:7001jndi-provider-url destination-jndi-name.Topic2destination-jndi-name session-transactedtruesession-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 nameJMSInboundAdaptername event-typeStockTickevent-type jndi-provider-urlt3:ppurich-pc:7001jndi-provider-url destination-jndi-name.Topic1destination-jndi-name session-transactedtruesession-transacted message-selector{CONDITION}message-selector bindings group-binding group-id=ActiveActiveGroupBean_group1 param id=CONDITIONacctid = 1000param group-binding group-binding group-id=ActiveActiveGroupBean_group2 param id=CONDITIONacctid 1000param group-binding bindings jms-adapter