How to Configure Simple Failover With Buffering

21-10 Oracle Complex Event Processing Developers Guide rules processor wlevs:config To configure light-weight queue trimming: 1. Create a multi-server domain using Oracle Coherence. For more information, see: ■ How to Create an Oracle CEP Multi-Server Domain With Default Groups Using Oracle Coherence in the Oracle Complex Event Processing Administrators Guide. ■ How to Create an Oracle CEP Multi-Server Domain With Custom Groups Using Oracle Coherence in the Oracle Complex Event Processing Administrators Guide. 2. Create an Oracle CEP application. For more information, see Section 4.2, Creating Oracle CEP Projects . 3. Edit the MANIFEST.MF file to add the following Import-Package entries: ■ com.bea.wlevs.ede.api.cluster ■ com.oracle.cep.cluster.hagroups ■ com.oracle.cep.cluster.ha.adapter ■ com.oracle.cep.cluster.ha.api For more information, see Section 4.7.2, How to Add an OSGi Bundle to an Oracle CEP Project . 4. Configure your Oracle CEP application EPN assembly file to add an Oracle CEP high availability input adapter as Example 21–15 shows: ■ Add a wlevs:adapter element with provider set to ha-inbound after the regular input adapter helloworldAdapter. ■ Add a wlevs:listener element to the regular input adapter helloworldAdapter that references the ha-inbound adapter by its id. ■ Add a wlevs:source element to the helloworldInputChannel that references the ha-inbound adapter by its id. Example 21–15 Light-Weight Queue Trimming EPN Assembly File: High Availability Input Adapter ?xml version=1.0 encoding=UTF-8? beans ... wlevs:event-type-repository wlevs:event-type type-name=HelloWorldEvent wlevs:classcom.bea.wlevs.event.example.helloworld.HelloWorldEventwlevs:class wlevs:event-type wlevs:event-type-repository wlevs:adapter id=helloworldAdapter class=com.bea.wlevs.adapter.example.helloworld.HelloWorldAdapter wlevs:instance-property name=message value=HelloWorld - the current time is: wlevs:listener ref=myHaInputAdapter wlevs:adapter wlevs:adapter id=myHaInputAdapter provider=ha-inbound wlevs:adapter Configuring High Availability 21-11 wlevs:channel id=helloworldInputChannel event-type=HelloWorldEvent wlevs:listener ref=helloworldProcessor wlevs:source ref=myHaInputAdapter wlevs:channel wlevs:processor id=helloworldProcessor wlevs:channel id=helloworldOutputChannel event-type=HelloWorldEvent advertise=true wlevs:listener bean class=com.bea.wlevs.example.helloworld.HelloWorldBean wlevs:listener wlevs:source ref=helloworldProcessor wlevs:channel beans 5. Configure your Oracle CEP application EPN assembly file to add an Oracle CEP high availability broadcast output adapter as Example 21–16 shows. ■ Add a wlevs:adapter element with provider set to ha-broadcast after channel helloworldOutputChannel. ■ Update the wlevs:listener element in channel helloworldOutputChannel to reference the ha-broadcast adapter by its id. ■ Add a wlevs:listener element to the ha-broadcast adapter that references the HelloWorldBean class. Example 21–16 Light-Weight Queue Trimming EPN Assembly File: Broadcast Output Adapter ?xml version=1.0 encoding=UTF-8? beans ... wlevs:event-type-repository wlevs:event-type type-name=HelloWorldEvent wlevs:classcom.bea.wlevs.event.example.helloworld.HelloWorldEventwlevs:class wlevs:event-type wlevs:event-type-repository wlevs:adapter id=helloworldAdapter class=com.bea.wlevs.adapter.example.helloworld.HelloWorldAdapter wlevs:instance-property name=message value=HelloWorld - the current time is: wlevs:listener ref=myHaInputAdapter wlevs:adapter wlevs:adapter id=myHaInputAdapter provider=ha-inbound wlevs:adapter wlevs:channel id=helloworldInputChannel event-type=HelloWorldEvent wlevs:listener ref=helloworldProcessor wlevs:source ref=myHaInputAdapter wlevs:channel wlevs:processor id=helloworldProcessor wlevs:channel id=helloworldOutputChannel event-type=HelloWorldEvent advertise=true wlevs:listener ref=myHaBroadcastAdapter wlevs:source ref=helloworldProcessor wlevs:channel wlevs:adapter id=myHaBroadcastAdapter provider=ha-broadcast 21-12 Oracle Complex Event Processing Developers Guide wlevs:listener bean class=com.bea.wlevs.example.helloworld.HelloWorldBean wlevs:listener wlevs:adapter beans 6. Configure the Oracle CEP high availability input adapter. Consider the following example configurations: ■ Example 21–17, High Availability Input Adapter: Default Configuration ■ Example 21–18, High Availability Input Adapter: Tuple Events ■ Example 21–19, High Availability Input Adapter: Key of One Event Property ■ Example 21–20, High Availability Input Adapter: Key of Multiple Event Properties For more information, see Section 21.2.1.1, High Availability Input Adapter EPN Assembly File Configuration . Example 21–17 High Availability Input Adapter: Default Configuration This example shows a high availability input adapter configuration using all defaults. The mandatory key is based on all event properties and the event property that the high availability input adapter assigns a time value to is an event property named arrivalTime. ... wlevs:adapter id=myHaInputAdapter provider=ha-inbound wlevs:instance-property name=timeProperty value=arrivalTime wlevs:adapter ... Example 21–18 High Availability Input Adapter: Tuple Events This example shows a high availability input adapter configuration using all defaults. The mandatory key is based on all event properties and the event property that the high availability input adapter assigns a time value to is an event property named arrivalTime. Because the events are tuple-based events, you must specify the event type MyEventType using the eventType property. ... wlevs:adapter id=myHaInputAdapter provider=ha-inbound wlevs:instance-property name=timeProperty value=arrivalTime wlevs:instance-property name=eventType value=MyEventType wlevs:adapter ... Example 21–19 High Availability Input Adapter: Key of One Event Property This example shows a high availability input adapter configuration where the mandatory key is based on one event property named id and the event property that the high availability input adapter assigns a time value to is an event property named arrivalTime. ... wlevs:adapter id=myHaInputAdapter provider=ha-inbound wlevs:instance-property name=keyProperties value=id wlevs:instance-property name=timeProperty value=arrivalTime wlevs:adapter ... Configuring High Availability 21-13 Example 21–20 High Availability Input Adapter: Key of Multiple Event Properties This example shows a high availability input adapter configuration where the mandatory key is based on more than one event property properties orderID and accountID and the event property that the high availability input adapter assigns a time value to is an event property named arrivalTime. A compound key Java class com.acme.MyCompoundKeyClass is mandatory and its implementation is shown in Example 21–21 . The hashCode and equals methods are required. When you specify a keyClass, the keyProperties instance property is ignored: Oracle CEP assumes that the compound key is based on all the getter methods in the keyClass. ... wlevs:adapter id=myHaInputAdapter provider=ha-inbound wlevs:instance-property name=timeProperty value=arrivalTime wlevs:instance-property name=keyClass value=com.acme.MyCompoundKeyClass wlevs:adapter ... Example 21–21 MyCompoundKeyClass Implementation package com.acme; public class MyCompoundKeyClass { private int orderID; private int accountID; public MyCompoundKeyClass {} public int getOrderID { return orderID; } public setOrderIDint orderID { this.orderID = orderID; } public int getAccountID { return accountID; } public setOrderIDint accountID { this.accountID = accountID; } public int hashCode { int hash = 1; hash = hash 31 + orderID.hashCode; hash = hash 31 + accountID == null ? 0 : accountID.hashCode; return hash; } public boolean equalsObject obj { if obj == this return true; if obj == null return false; if obj instanceof MyCompoundKeyClass return false; MyCompoundKeyClass k = MyCompoundKeyClass obj; return k.accountID == accountID k.orderID == orderID; } } 7. Configure the channel downstream from the high availability input adapter helloworldInputChannel to configure an application timestamp based on the high availability input adapter timeProperty setting as Example 21–22 shows. The wlevs:expression should be set to the timeProperty value. 21-14 Oracle Complex Event Processing Developers Guide Example 21–22 Application Timestamp Configuration ... wlevs:adapter id=myHaInputAdapter provider=ha-inbound wlevs:instance-property name=keyProperties value=id wlevs:instance-property name=eventType value=HelloWorldEvent wlevs:instance-property name=timeProperty value=arrivalTime wlevs:adapter wlevs:channel id=helloworldInputChannel event-type=HelloWorldEvent wlevs:listener ref=helloworldProcessor wlevs:source ref=myHaInputAdapter wlevs:application-timestamped wlevs:expressionarrivalTimewlevs:expression wlevs:application-timestamped wlevs:channel ... 8. Configure the Oracle CEP high availability broadcast output adapter. Consider the following example configurations: ■ Example 21–23, Broadcast Output Adapter: Default Configuration ■ Example 21–24, Broadcast Output Adapter: Key of One Event Property ■ Example 21–25, Broadcast Output Adapter: Key of Multiple Event Properties For more information, see Section 21.2.3.1, Broadcast Output Adapter EPN Assembly File Configuration . Example 21–23 Broadcast Output Adapter: Default Configuration This example shows a broadcast output adapter configuration using all defaults. The mandatory key is based on all event properties, key values are nonmonotonic do not increase continually and total order unique. ... wlevs:adapter id=myHaSlidingWindowAdapter provider=ha-buffering wlevs:listener bean class=com.bea.wlevs.example.helloworld.HelloWorldBean wlevs:listener wlevs:adapter ... Example 21–24 Broadcast Output Adapter: Key of One Event Property This example shows a broadcast output adapter configuration where the mandatory key is based on one event property named timeProperty, key values are monotonic they do increase continually and not total order not unique. ... wlevs:adapter id=myHaSlidingWindowAdapter provider=ha-buffering wlevs:listener bean class=com.bea.wlevs.example.helloworld.HelloWorldBean wlevs:listener wlevs:instance-property name=keyProperties value=timeProperty wlevs:instance-property name=monotonic value=true wlevs:instance-property name=total-order value=false wlevs:adapter ... Example 21–25 Broadcast Output Adapter: Key of Multiple Event Properties This example shows a broadcast output adapter configuration where the mandatory key is based on more than one event property properties timeProperty and