Specifying the Key Used to Index an Oracle CEP Local Cache

12-14 Oracle Complex Event Processing Developers Guide wlevs:cache-loader ref=cache-loader-id wlevs:cache ... bean id=cache-loader-id class=wlevs.example.MyCacheLoader In the example, the cache-loader-id Spring bean does the cache loading work; it is referenced by the cache using the ref attribute of the wlevs:cache-loader child element. You must program the wlevs.example.MyCacheLoader class yourself, and it must implement the com.bea.cache.jcache.CacheLoader interface. This interface includes the load method to customize the loading of a single object into the cache; Oracle CEP calls this method when the requested object is not in the cache. The interface also includes loadAll methods that you implement to customize the loading of the entire cache.

12.2.4 Configuring an Oracle CEP Local Cache Store

You can configure an Oracle CEP local cache with a custom store that is responsible for writing data from the cache to a backing store, such as a table in a database. You configure a cache store by using the wlevs:cache-store child element of the wlevs:cache element to specify the bean that does the actual storing work, as shown in the following example: wlevs:caching-system id=caching-system-id ... wlevs:cache id=cache-id name=alternative-cache-name wlevs:caching-system ref=caching-system-id wlevs:cache-store ref=cache-store-id wlevs:cache ... bean id=cache-store-id class=wlevs.example.MyCacheStore In the example, the cache-store-id Spring bean does the work of writing the data from the cache to the backing store; it is referenced by the cache using the ref attribute of the wlevs:cache-store child element. You must program the wlevs.example.MyCacheStore class yourself, and it must implement the com.bea.cache.jcache.CacheStore interface. This interface includes the store method that stores the data in the backing store using the passed key; Oracle CEP calls this method when it inserts data into the cache. The interface also includes the storeAll method for storing a batch of data to a backing store in the case that you have configured asynchronous writes for a cache with the write-behind configuration element.

12.3 Configuring an Oracle Coherence Caching System and Cache

You can configure your application to use the Oracle Coherence caching system and cache. Use this caching system if you plan to deploy your application to a multi-server domain. Using Oracle Coherence, only the first caching-system can be configured in a server. Oracle CEP will ignore any other caching systems you might configure. Configuring Caching 12-15 To configure an Oracle Coherence caching system and cache: 1. Decide whether or not your Oracle Coherence cache will be used exclusively by this application or shared amongst two or more applications. For more information, see Section 12.3.5, Configuring a Shared Oracle Coherence Cache . 2. Declare the Oracle Coherence caching system in the EPN assembly file. To declare a caching system that uses the Oracle Coherence implementation declaratively in the EPN assembly file, use the wlevs:caching-system element as shown in the following example: wlevs:caching-system id=caching-system-id provider=coherence advertise=false The value of the id attribute must match the name you specify for the caching system in the application’s component configuration file see step 4. 3. Declare one or more caches for this caching system in the EPN assembly file. After you have declared a caching system for an application, you configure one or more caches using the wlevs:cache element: wlevs:caching-system id=caching-system-id provider=coherence advertise=false ... wlevs:cache id=myCache advertise=false wlevs:caching-system ref=caching-system-id wlevs:cache The wlevs:cache element id attribute is mandatory. This attribute maps to the name of a cache in the Oracle Coherence configuration files see step 4. The name attribute is optional; specify it only if the name of the cache in the caching system is different from its ID. The wlevs:caching-system child element references the already-declared caching system that contains the cache. You must specify this child element only if the caching system is ambiguous: there is more than one caching system declared either implicitly or explicitly or if the caching system is in a different application or bundle. Note: Before you can legally use Oracle CEP with Oracle Coherence, you must obtain a valid Coherence license such as a license for Coherence Enterprise Edition, Coherence Grid Edition, or Oracle WebLogic Application Grid. For more information on Oracle Coherence, see http:www.oracle.comtechnologyproductscoherence index.html . Note: It is assumed in this section that you have already created an Oracle CEP application along with its EPN assembly file and that you want to update the application to use caching. If you have not, refer to Chapter 1, Overview of Creating Oracle CEP Applications for details. 12-16 Oracle Complex Event Processing Developers Guide The caching system is responsible for creating the cache associated with a particular name and returning a reference to the cache. The resulting cache bean implements the java.util.Map interface. For more information, see Section 12.3.5, Configuring a Shared Oracle Coherence Cache . 4. Configure the caching system and its caches by updating the caching configuration file for the application. See Section 12.3.1, Configuring the Oracle Coherence Caching System and Caches. 5. Optionally, override the default cache configuration by updating the EPN assembly file with one or more additional cache element child elements. ■ Specify that a cache is an event sink by configuring it as a listener to another component in the event processing network. See Section 12.3.1, Configuring the Oracle Coherence Caching System and Caches. ■ Specify that a cache is an event source to which another component in the event processing network listens. See Section 12.3.2, Configuring an Oracle Coherence Cache as an Event Listener. ■ Configure either a wlevs:cache-loader or a wlevs:cache-store child element of the wlevs:cache element in the EPN assembly file, but not both. This is because Oracle Coherence combines the loader and store into a single component. You specify a cache loader when the backing store is read-only and a cache store when the backing store is read-write See Section 12.3.4, Configuring an Oracle Coherence Cache Loader or Store. 6. Access the Oracle Coherence cache: – Optionally reference the Oracle Coherence cache in a query statement. See: Section 12.5, Accessing a Cache From an Oracle CQL Statement Section 12.6, Accessing a Cache From an EPL Statement – Optionally configure and program a custom adapter, business POJO, or Oracle CQL or EPL user-defined function to access the Oracle Coherence cache. The configuration is done in the EPN assembly file and the programming is done in the Java file that implements the adapter, POJO, or user-defined function. See: Section 12.7, Accessing a Cache From an Adapter Section 12.8, Accessing a Cache From a Business POJO Section 12.9, Accessing a Cache From an Oracle CQL User-Defined Function Section 12.10, Accessing a Cache From an EPL User-Defined Function – Optionally, access the Oracle Coherence cache using JMX.