Event-Driven Architecture导学

rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cj104li%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml">

首先,还是wikihttp://en.wikipedia.org/wiki/Event-driven_architecture

这篇wiki很清楚的介绍了Event-driven architecture的概念和相关知识。提到了所谓的“松耦合”的软件架构SOA

文中重点描述了event-driven的架构层次和三种Event Processing Styles

 

层次包括了四层:

       1. Event generator. 就是产生event的终端或者sensor。将所要表述的信息封装成一个event,其中,如何采用一个合理的format使得event的可读性非常好是一个问题。

       2. Event channel. 主要就是event的传输机制。可能是TCP/IP,或者是XML格式等等。一般来说,“because the event processing engine has to process them in near real time, the event channels will be read asynchronously. The events are stored in a queue, waiting to be processed later by the event processing engine.”。

       3. Event processing engine. 用来辨识event,并采取合理的reaction

       4. downstream activity. 很多时候,engine只是触发合理的reaction,而真正的动作是在这里完成的。所以,这一步并不是必须的。

 

三种Styles

       1. Simple event processing. 普通的架构。在这里,所有的event都是notable的,都应该做出reaction

       2. Event stream processing.

       http://en.wikipedia.org/wiki/Event_Stream_Processing

       基于event流的架构。

       在这个架构中,event generator产生持续的event,这些event既有notable的,但更多的是ordinary,这就需要EPE能够对event进行过滤和识别。”Stream event processing is commonly used to drive the real-time flow of information in and around the enterprise, which enables in-time decision making.”

       3. Complex event processing.

       http://en.wikipedia.org/wiki/Complex_event_processing_(CEP)

       复杂event的处理架构。

       在这种架构中,存在着大量的simple event,这些event之间有着各种联系。CEP系统要求能够发现这些联系,从simple events中提取出复杂的event

       文中举了个例子。例如,如果有简单的event,包括“男的穿了燕尾服”,“女的穿婚纱”,“地点在教堂”,那么我们就能够提取出复杂的eventwedding”。

 

我个人观点,Styles23并不是一个互斥的关系。相反,它们其实是可以结合的。2重点强调的是实时的decision3强调的则是对复杂事情的处理。


rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cj104li%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml">

离开wiki,让我们来看点文章。

Event-Dirven Architecture Overview》中不仅提到了上面的4个层次和三种styles,而且还谈到了一个EDA需要的5种组件:

rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cj104li%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml">

     Event Metadata:事件元数据包括事件说明和事件处理规则;

     Event Processing:事件处理的核心是引擎和事件发生数据;

     Event Tooling:事件开发工具用于定义事件说明和事件规则,以及管理订阅等。事件管理工具提供事件处理基础架构的管理和监测,事件流的监测以及显示事件生成和处理状态等;

     Event Integration:一个企业集成中枢在事件驱动架构中扮演着重要的角色。需要集成的一些服务包括:事件预处理(过滤、路由和转变等)、事件通道传输、服务调用、业务流程调用、发布和订阅,以及企业信息访问等;

     Sources and Targets:创建事件和/或执行一个事件驱动动作的企业资源(应用、服务、业务流程、数据存储、人员和自动代理等)。


rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cj104li%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml">

此外,InfoQ上的两篇文章《Gartner论述平台中间件中的分裂趋势》和《关于复杂事件处理和事件驱动架构的争论》对于CEPEDA进行了一些探讨,其中的一句话我尤其赞同:

“我不认同那些努力传播SOA的同学们所说的“EDA只是SOA的一个子集的论断。一个更广泛的事件驱动架构概念,不仅是超越事件驱动SOA的,还应该包括实时信息流和分析,以及复杂事件处理。”

现在大多数人(包括很多专家)都是从SOA的角度来看待EDA,将它当作是SOA的升级版或者是补充,但EDA会有更加广阔的前景。


rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cj104li%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"> rel="Edit-Time-Data" href="file:///C:%5CDOCUME%7E1%5Cj104li%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_editdata.mso">

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Event-driven programming is a programming paradigm that allows the software to respond to events or user actions in a asynchronous manner. Here are the general steps to implement an event-driven program: 1. Identify the events: Determine the events that the program needs to respond to. These could be user actions, system events, or external signals. 2. Define event handlers: Create functions or methods to handle each event. These functions will be executed when the event occurs. 3. Register event handlers: Associate each event handler with the corresponding event. This is usually done using a framework or library. 4. Run the program: Once the event handlers are registered, the program is ready to execute. As events occur, the associated event handlers will be executed. 5. Clean up: After the program finishes executing, clean up any resources used or allocated during the program. Here's an example of an event-driven program in Python using the Tkinter GUI library: ```python import tkinter as tk def button_click(event): print("Button clicked") root = tk.Tk() button = tk.Button(root, text="Click me") button.bind("<Button-1>", button_click) button.pack() root.mainloop() ``` In this program, we identify the event as a button click, define an event handler function `button_click` to handle the event, register the event handler with the button using the `bind` method, and run the program using the `mainloop` method. When the button is clicked, the `button_click` function will be executed and print "Button clicked" to the console.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值