Archive

Archive for the ‘Complex Event Processing’ Category

Oracle Event Processing – Pattern Matching Example 2

In previous post I showed off one of the pattern matching feature of Oracle Event Processing and in this section I am gonna show another example of it.

There are many built-in functions which can be used in CQL. I think one of the most important these functions is the prev function. Prev function facilitates accessing the previous elements in the same stream/partition easily.

Consider this scenario, we have stock values as below and I would like to find out the pattern; firstly average value of previous 3 elements should be greater than 10 and the last value greater than the last value of the previous condition.

If we want to write to CQL code of our requirements it would look like:

CQL Example

With numbers lets try to understand how the pattern can be matched ( left side: incoming events; right side: expression about pattern matching):

Events and patterns

 

Run the application:

output

As shown in above, after the 13 and 33 pattern has been matched and output was produced.

 

 

Advertisements

Oracle Event Processing – Pattern Matching Example

Event processing technologies became famous in recent years. Companies realizes that they need to take real time action in order to satisfy customer requirements or handle several component issues happened in some internal system or advertising etc.

Oracle Event processing has several processing methods in order to process incoming real time data. In this blog post I will show off one of the pattern matching operations.

Consider, you desire to find out which stock firstly increases then decreases three times and increases again. For example;

6.48;6.47;6.46;6.48;6.49;6.48;6.47;6.46;6.47;6.46;6.45;6.44;6.43;6.42;6.43

In the above numbers we will find out the pattern which starts with 6.48 and ends with 6.47. Because it firstly incremented from 6.48 to 6.49 and then decreased three times ( 6.48,6.47,6.46 ) and then increased from 6.46 to 6.47 again.

I am using the Oracle Event Processing 11.1.1.7 for Windows 64bit and Cygwin as windows terminal.

I changed a little bit the HelloWorld default cep application. The most crucial part is the CQL Processor part, how should I implement the CQL in order to find out the patterns?

OCEP Cql Processor Pattern Matching

OCEP Cql Processor Pattern Matching

Let’s look at the clauses in briefly.

StockProcessor is the name of the cql processor.
PARTITION BY shortName: Partition incoming data by shortName ( CQL Engines calculates each partition individually. For example, ORCL, IBM, GOOG prices are computed individually. )
MEASURES : Which values, fields will be in the output
PATTERN : Order of conditions ( Look at regular expression for more details )
DEFINE : Defining the conditions, “A as” means the define condition A.

Run the application and type the stock name and prices as in below:

OCEP Cql Processor Pattern Matching Demo

OCEP Cql Processor Pattern Matching Demo

Just after pattern is matched the output event is produced and in this example I just printed the name and last price value of the stock.

I didn’t specify any performance measurements but if the number of distinct stocks are increased performance will be our first concern. However, I would like to share some performance results in a another blog post later.

The Book: Getting Started with Oracle Event Processing 11g

Packt Publishing is the UK based tech book publishers which will publish an expected book in a few days.

Besides, this book is the my first book which I am the one of the reviewer:

Getting Started with Oracle Event Processing 11g

Getting Started with Oracle Event Processing 11g

The one of the authors is the Robin J. Smith who is a great and much more experienced IT man who I met in the Istanbul at a lunch. The people who are looking for a book which tells the concepts of the Event Processing with really good designed examples and includes much more detail about the Oracle Event Processing 11g product; this book is definitely for you.

Oracle CEP Bug – org.springframework.beans.TypeMismatchException

I have installed the Oracle Complex Event Processing 11.1.3. I will have described what I am doing by the end of this month. Anyway I decided to use Event
Partitioning feature to achieve scalability. When I use a channel with event partitioning feature I was getting error :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name

‘inputChannel’: Invocation of init method failed; nested exception is

org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert

property value of type [java.lang.String] to required type

[com.bea.wlevs.channel.EventPartitioner] for property ‘eventPartitioner’; nested exception is

java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required

type [com.bea.wlevs.channel.EventPartitioner] for property ‘eventPartitioner’: no matching

editors or conversion strategy found

In CEP documentation,
( Section 19.1, “How to Configure Scalability With an Event Partitioner Channel” )

it says we could achieve scalability by putting this piece of code into channel configuration part of EPN assembly file:

<wlevs:instance-property name=”eventPartitioner” value=”true” />

However, it does not working. I created a Metalink SR and they answered me as they filed a bug about this issue(9964253).

Getting rid of this error is simple. Change name of instance-property from “eventPartitioner” to “partitionByEventProperty” and change value parameter to a varible name of your Event Class like this:

<wlevs:instance-property name=”partitionByEventProperty” value=”symbol” />

Your event class should have a “symbol” variable.

public String symbol;