Last month I’ve completed my bachelor thesis on the Integration of Complex Event Processing (CEP) into a programming language. In a nutshell, I’ve combined the interface of EScala, a Scala DSL that features simple to use events as object attributes (similar to C#) with Esper, a Java CEP engine.
My library allows the use of Esper while writing type safe Scala code that is statically checked at compile-time; there is no need of using Esper’s own Event Processing Language (EPL) anymore. If you’re interested in my work you can have a look at the presentation or read my bachelor thesis. The corresponding code is accessible via GitHub.
Here are some quick examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
// Declaring Events // with one property val e1 = new ImperativeEvent[Int] // with multiple properties val e2 = new ImperativeEvent[(Int, String)] val e3 = new ImperativeEvent[(Int, String)] // Declaring a Reaction val r2 = (e: (Int, String)) => println(e._2) // Binding a Reaction to an Event e2 += r2 // Triggering an Event e2(42, “Hello World!”) // Transforming an Event val e4 = e2.map((e: (Int, String)) => e._2.length) // Filtering an Event val predicate = (int: Int, string: String) => int == 42 val e5 = e2 && predicate // Composing Events val e6 = e2 || e3 // Joining Events val e7 = e2 join e3 window time(30 sec) on ((a,b) => a._1===b._1) // Declaring and binding a Reaction to a Joined Event // (a joined event contains all properties of the underlying events) val r7 = (e: (Int, String, Int, String)) => println(e._2 + “ “ + e._4) e7 += r7 // Declaring a Repeat Event Pattern // corresponds to every [n] event in Esper, cf. // http://esper.codehaus.org/esper-4.10.0/doc/reference/en-US/html/event_patterns.html#pattern-repeat val e8 = e2 repeat 3 // Declaring and binding a Reaction to a Repeat Event Pattern val r8 = (e: Seq[[(Int, String)]) => println(e(0)._2 + “ “ + e(1)._2 + “ “ + e(2)._2) e8 += r8 |