The Signal Generation Component Configuration Files

3-118 Oracle Complex Event Processing Getting Started wlevs:processor id=processor1 wlevs:cache-source ref=symbolsCache wlevs:processor The listener attribute, common to all component tags, specifies the component that listens to the processor; in this case, the listener is symbolsCache. – The wlevs:caching-system element specifies the Oracle CEP local event cache the application uses to improve performance, for example: wlevs:caching-system id=signalgenCachingSystem wlevs:cache id=symbolsCache key-properties=symbol value-type=Symbols wlevs:caching-system ref=signalgenCachingSystem wlevs:cache-loader ref=symbolsCacheLoader wlevs:cache For more information on caches, see Configuring Oracle CEP Caching in the Oracle Complex Event Processing Developers Guide for Eclipse.

3.10.6 The Signal Generation Component Configuration Files

The Signal Generation application configures its processor and cache in a component configuration file that Example 3–10 shows. Example 3–10 Signal Generation Component Configuration File ?xml version=1.0 encoding=UTF-8? -- this is here to test that we ignore this file -- n1:config xsi:schemaLocation=http:www.bea.comnswlevsconfigapplication wlevs_ application_config.xsd xmlns:n1=http:www.bea.comnswlevsconfigapplication xmlns:xsi=http:www.w3.org2001XMLSchema-instance processor nameprocessor1name rules view id=S schema=symbol price [CDATA[ RStreamselect T.symbol, T.lastPrice from StockTickStream[now] as T, symbolsCache as R where T.symbol = R.symbol ]] view query id=percent [CDATA[ select symbol, lastPrice, percentLastPrice, startTimestamp from S MATCH_RECOGNIZE PARTITION BY symbol MEASURES B.symbol as symbol, B.price as lastPrice, 100B.price - A.priceA.price as percentLastPrice, B.ELEMENT_TIME as startTimestamp ALL MATCHES PATTERN A B DEFINE B AS 100B.price - A.priceA.price 2.0 or 100B.price - A.priceA.price -2.0 as T ]] query view id=vTrend schema=symbol lastPrice trendLastPrice [CDATA[ Oracle CEP Samples 3-119 select symbol, lastPrice, trendLastPrice from S MATCH_RECOGNIZE PARTITION BY symbol MEASURES Z.symbol as symbol, Z.price as lastPrice, countA.-countB. as trendLastPrice ALL MATCHES PATTERN X A|B|C A|B|C A|B|C A|B|C SUBSET Z = A, B, C DEFINE A AS A.price PREVA.price, B AS B.price PREVB.price, C AS C.price = PREVC.price as T ]] view query id=trend [CDATA[ select symbol, lastPrice, trendLastPrice, ELEMENT_TIME as startTimestamp from vTrend where trendLastPrice 2 ]] query rules processor channel nameTrendStreamname selectortrendselector channel channel namePercentStreamname selectorpercentselector channel n1:config If your application contains multiple processors, adapters or channels, you can either declare them all in a single configuration file, or create separate configuration files for each component; the method you chose depends on which you find easier to manage. For each component you configure, you must add the name child element to explicitly declare the specific component to which you are referring. The value of the name element must correspond to the components unique identifier of its declaration in the EPN assembly file. For example, assume a processor is declared in the EPN assembly file as follows: wlevs:processor id=processor1 ... Then its corresponding XML configuration would be as follows: processor nameprocessor1name ... processor The Signal Generation example uses a single configuration file for one processor with the name processor1 and one cache with the name symbolsCache. These names correspond with the declaration of the components in the EPN assembly file. The processor element configures the processor component. The most important part of the processor configuration is the declaration of the set of Oracle Continuous Query Language Oracle CQL rules that this processor executes; these rules select the set of events that are eventually passed to the application business object. Each rule is declared with a query or relation element using an XML [CDATA[...]] 3-120 Oracle Complex Event Processing Getting Started section; all query and relation elements are grouped together within a single rules element. You can define as many rules as you want for a particular processor. The Signal Generation application has the following rules: rules view id=S schema=symbol price [CDATA[ RStreamselect T.symbol, T.lastPrice from StockTickStream[now] as T, symbolsCache as R where T.symbol = R.symbol ]] view query id=percent [CDATA[ select symbol, lastPrice, percentLastPrice, startTimestamp from S MATCH_RECOGNIZE PARTITION BY symbol MEASURES B.symbol as symbol, B.price as lastPrice, 100B.price - A.priceA.price as percentLastPrice, B.ELEMENT_TIME as startTimestamp ALL MATCHES PATTERN A B DEFINE B AS 100B.price - A.priceA.price 2.0 or 100B.price - A.priceA.price -2.0 as T ]] query view id=vTrend schema=symbol lastPrice trendLastPrice [CDATA[ select symbol, lastPrice, trendLastPrice from S MATCH_RECOGNIZE PARTITION BY symbol MEASURES Z.symbol as symbol, Z.price as lastPrice, countA.-countB. as trendLastPrice ALL MATCHES PATTERN X A|B|C A|B|C A|B|C A|B|C SUBSET Z = A, B, C DEFINE A AS A.price PREVA.price, B AS B.price PREVB.price, C AS C.price = PREVC.price as T ]] view query id=trend [CDATA[ select symbol, lastPrice, trendLastPrice, ELEMENT_TIME as startTimestamp from vTrend where trendLastPrice 2 ]] query rules For more information, see Oracle Complex Event Processing CQL Language Reference.

3.11 Event Record and Playback Example