Drools Fusion介绍
Drools Fusion介绍
规则通常或多或少操作于静态数据集(事实)。然而,对于一些系统,有必要定义时间关联的事实。他们通常叫做复杂时间处理(CEP)或者是事件流处 理(ESP)。Drools Fusion,从5.0版本开始,提供了滑动窗体(sliding windows),时间运算符(temporal operators),类型声明(type declarations)于一体的支持。
CEP 和 ESP
CEP 和 ESP 是 事件驱动架构(Event Driven Architecture)处理模式(更多关于事件处理架构的信息:
http://elementallinks.typepad.com/bmichelson/2006/02/eventdriven_arc.html)。 这个架构的一个主要的好处就是提供了组件的松耦合。一个组件可以发布正在执行的动作事件,其他组件可以订阅/监听这些事件。发布者和订阅者不知道对方的存 在。一个订阅监听事件者不关心事件的来源。相似的,产生事件的生产者也不知道任何监听这些事件者的任何事情。一些编排层处理实际的订阅、发布之间的装配。
一个事件代表有意义状态的改变。它通常由一个事件头和事件体组成。事件头包含了名称,发生时间,持续时间等元信息。事件体描述了发生了什么。例如,如果一个银行交易被处理,事件体应该包含交易的ID,交易数量,本人帐号,转账帐号等。
CEP 处理复杂事件。一个复杂事件是简单事件的集合。比如,一系列的巨额提款激发可疑交易事件的发生。一个复杂事件的发生是由一系列简单事件的引导形成的。
ESP 是更实时(real-time)的大量事件处理。例如,根据时间计算实时平均交易量。
更多关于CEP和ESP的信息:http://complexevents.com/ 、由作者Prof. David Luckham编写的《The Power of Events》。这本书被认为当今研究和发展CEP的里程碑。
现在有很多完整的CEP/ESP 引擎,包括商业的和开源的。Drools Fusion支持事件以增强编程式规则。它使用Rete算法并提供一个可选的引擎。
Drools Fusion
Drools Fusion 是业务逻辑集成平台(Business Logic Integration
Platform)一部分的一个Drools模块。Drools事件处理引擎支持CEP和ESP。每个事件有一个类型,一个发生时间,它也许还有 持续时间。时间点(零持续时间) 和基于时间间隔的事件都是被支持的。事件也可以像其他事实一样包含其他数据——name和type属性。所有的事件都是事实但是并不是所有的事实都是事 件。一个时间的状态不应该被改变。不过,给没有赋值的值赋值是合法的。事件有一个明确的生命周期窗,当生命周期窗结束后可能有透明的垃圾回收机制(比如, 我们只对最近24小时内交易感兴趣)。规则能够处理事件之间的时间关系。
[quote=homer]
谈到开源CEP,Esper出得比较早了, 性能很高。http://esper.codehaus.org
我的一个朋友已用于制造业项目的CEP应用。
[/quote]
个人觉得CEP在BAM上的应用应该非常的合适,好像国外一些先进流程厂商的BAM也是基于CEP来实现的,而BAM个人觉得也完全可以基于CEP做成一个独立的框架系统,不知的homer对此如何见解?有没有一些研究或资料能共享出来?
个人认为,若是配套BPMS产品的BAM,主要是面向BPMS已设定的可执行流程进行统计分析,事件源是单一的(往往取数据库中信息进行统计和分析展现就行了),这种情况下就没必要采用CEP技术。
从国外产品看,CEP一般是发展为一个独立产品,可以实时采集和关联处理多个事件源(如采集BPMS中事件、来自工业控制机的事件、来自数据库的Trigger事件等等)。
在《Open Source SOA》这本书中,作者讨论了BI/BAM/ESP的区别:
BI, BAM, and ESP: are they all the same thing?
Business intelligence (BI) refers broadly to the technologies
and applications used to analyze and present business information
to targeted business consumers. Business activity monitoring (BAM),
though similar to BI, tends to focus on real-time analysis of
information.
BI, on the other hand, often works in conjunction with data
warehousing technologies to present analytics on historically
gathered data. ESP shares the same real-time monitoring emphasis
as BAM, but the source of data is derived directly from event
streams. Historically, BAM solutions might cull real-time data
from transaction records or BPM systems, but now are being
enhanced to support ESP. So, BAM can be considered a super-set
of ESP.
BAM and ESP—what’s the difference?
There is no doubt some confusion as to what are essentially two
complementary technologies. BAM is often considered, in broad terms,
to encompass all aspects of monitoring, from data collection, to
transformation/analysis, to presentation. I prefer a more narrow
interpretation, where BAM is thought of as the presentation layer
but data collection is the purview of systems such as ESP. In other
words, ESP is a delivery channel for BAM. Why this distinction?
In part, as with web development, it’s prudent to isolate or partition
the various tiers involved in the monitoring process. Event publishing
, collection, rule processing and interpretation, and presentation
should each be considered separate tiers that are only loosely bound.
This allows changes, for instance, to be made to the presentation layer
without impacting the collection and interpretation layers. Indeed, a
multitude of presentations may be necessary, from iPhone or Blackberry,
to conventional web clients, to RSS feeds. Thus we refer to BAM, moving
forward, as limited in scope to the display and presentation of information
collected and analyzed via ESP.
Now let’s conclude our theoretical discussion by briefly examining ESP’s
role within the context of an EDA. Some believe that CEP requires EDA, but
as we’ll see, this need not be the case.
The role of an ESP is to receive multiple streams of real-time data and to,
in turn, detect patterns among the events. A variety of filters, time-based
aggregations, triggers, and joins are typically used by the ESP
to assist in pattern detection. The interpreted results from the ESP can
then be fed into business activity monitoring (BAM) dashboards.


谈到开源CEP,Esper出得比较早了, 性能很高。http://esper.codehaus.org
我的一个朋友已用于制造业项目的CEP应用。