http://esper.codehaus.org/nesper/documentation/documentation.html

环境配置

  1. NEsper库下载:下载网址
  2. Vs2010环境集成

在项目中添加下载的dll文件下的库即可。

  • Demo展示

事件类:

  1. public class ObjectEvent
  2. {
  3. public String itemName;
  4. public double price;
  5. public ObjectEvent(String itemName, double price)
  6. {
  7. this.itemName = itemName;
  8. this.price = price;
  9. }
  10. public String GetItemName()//命名规则必需正确,大小写不对会导致错误
  11. {
  12. return itemName;
  13. }
  14. public double GetPrice()
  15. {
  16. return price;
  17. }
  18. }
public class ObjectEvent
{
public String itemName;
public double price;
public ObjectEvent(String itemName, double price)
{
this.itemName = itemName;
this.price = price;
}
public String GetItemName()//命名规则必需正确,大小写不对会导致错误
{
return itemName;
}
public double GetPrice()
{
return price;
}
}

事件发送类

  1. class EventSender
  2. {
  3. private static EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider();
  4. static public void objectEventSend()
  5. {
  6. Configuration config = new Configuration();
  7. EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider();
  8. String epl =
  9. "select *,sum(Price) from ConsoleApplicationNesper.ObjectEvent.win:length(2)";
  10. EPStatement statement = epService.EPAdministrator.CreateEPL(epl);
  11. statement.Events += EventListener.objectEventHandle;
  12. ObjectEvent e = new ObjectEvent("shirt", 74.50);
  13. Console.WriteLine("send shirt:74.50");
  14. epService.EPRuntime.SendEvent(e);
  15. ObjectEvent e1 = new ObjectEvent("shoes", 60.50);
  16. Console.WriteLine("send shoes:60.50");
  17. epService.EPRuntime.SendEvent(e1);
  18. ObjectEvent e2 = new ObjectEvent("coat", 70.50);
  19. Console.WriteLine("send coat:70.50");
  20. epService.EPRuntime.SendEvent(e2);
  21. Console.ReadKey();
  22. }
  23. }
class EventSender
{
private static EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider();
static public void objectEventSend()
{
Configuration config = new Configuration();
EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider();
String epl =
"select *,sum(Price) from ConsoleApplicationNesper.ObjectEvent.win:length(2)"; EPStatement statement = epService.EPAdministrator.CreateEPL(epl);
statement.Events += EventListener.objectEventHandle; ObjectEvent e = new ObjectEvent("shirt", 74.50);
Console.WriteLine("send shirt:74.50");
epService.EPRuntime.SendEvent(e);
ObjectEvent e1 = new ObjectEvent("shoes", 60.50);
Console.WriteLine("send shoes:60.50");
epService.EPRuntime.SendEvent(e1);
ObjectEvent e2 = new ObjectEvent("coat", 70.50);
Console.WriteLine("send coat:70.50");
epService.EPRuntime.SendEvent(e2); Console.ReadKey();
}
}

事件监听类

  1. class EventListener
  2. {
  3. static public void objectEventHandle(Object sender, UpdateEventArgs e)
  4. {
  5. EventBean eventResult = e.NewEvents[0];
  6. Console.WriteLine("sumPrice:" + eventResult.Get("sum(Price)"));
  7. Console.WriteLine("received: " + eventResult.Get("ItemName") + ":"
  8. + eventResult.Get("Price"));
  9. //Console.ReadKey();
  10. }
  11. }
class EventListener
{
static public void objectEventHandle(Object sender, UpdateEventArgs e)
{
EventBean eventResult = e.NewEvents[0];
Console.WriteLine("sumPrice:" + eventResult.Get("sum(Price)"));
Console.WriteLine("received: " + eventResult.Get("ItemName") + ":"
+ eventResult.Get("Price"));
//Console.ReadKey();
}
}

运行结果

  1. 1---object event example
  2. send shirt:74.50
  3. sumPrice:74.5
  4. received: shirt:74.5
  5. send shoes:60.50
  6. sumPrice:135
  7. received: shoes:60.5
  8. send coat:70.50
  9. sumPrice:131
  10. received: coat:70.5

NEsper事件处理 z的更多相关文章

  1. 【Python】使用torrentParser1.03对多文件torrent的分析结果

    Your environment has been set up for using Node.js 8.5.0 (x64) and npm. C:\Users\horn1>cd C:\User ...

  2. 事件流处理框架NEsper for .NET z

    复合事件处理(Complex Event Processing)介绍提到了开源的Esper,NEsper 是一个事件流处理(Event Stream Processing,ESP)和复杂事件处理(Co ...

  3. NEsper z

    对实时信息分析和处理,常常需要客户应用程序的开发相应功能.一般地,这些功能需要提供以下的处理流程,分析获取的数据,筛选数据,提取出有用的信息,然后将其通过特定的形式展现出来.由于具体实时信息的高并发性 ...

  4. NESPER的大体结构 z

    NEsper从内容上分为两块,NEsper的核心NEsper.dll和NEsper.IO.dll. (1)NEsper的核心包包含了EPL语法解析引擎,事件监听机制,事件处理等核心模块. (2)NEs ...

  5. NEsper使用的事件类型 z

    NEsper使用的事件类型来描述事件的类型信息.你的应用在启动时可能预先配置定义事件类型,或者在运行时通过API或EPL语法动态的增加事件类型. EPL中的create schema 的语法允许在运行 ...

  6. NEsper Nuget包

    Esper是专门进行复杂事件处理(CEP)的流处理平台,Java版本为Esper,.Net版本为NEsper.Esper & NEsper可以方便开发者快速开发部署处理大容量消息和事件的应用系 ...

  7. Qt Quick鼠标事件处理、键盘、计时器

    在<Qt Quick 事件处理之信号与槽>中介绍了 QML 中怎样使用内建类型的信号以及怎样自己定义信号,这次我们来看看怎样处理鼠标.键盘.定时器等事件.这些时间在处理时,一般是通过信号来 ...

  8. Microsoft .Net Remoting系列专题之三:Remoting事件处理全接触

    前言:在Remoting中处理事件其实并不复杂,但其中有些技巧需要你去挖掘出来.正是这些技巧,仿佛森严的壁垒,让许多人望而生畏,或者是不知所谓,最后放弃了事件在Remoting的使用.关于这个主题,在 ...

  9. 【转】Microsoft .Net Remoting之Remoting事件处理全接触

    Remoting事件处理全接触 前言:在Remoting中处理事件其实并不复杂,但其中有些技巧需要你去挖掘出来.正是这些技巧,仿佛森严的壁垒,让许多人望而生畏,或者是不知所谓,最后放弃了事件在Remo ...

随机推荐

  1. SQL Server 2012 读写分离设置

    SQL Server 2012 读写分离设置 - AlsoIn 时间 2014-07-21 17:38:00  博客园-所有随笔区 原文  http://www.cnblogs.com/also/p/ ...

  2. 查找计算机IP及占用端口

    1. 在电脑启动搜索框,输入cmd回车打开命令提示符窗口. 输入ipconfig,就可以查看电脑的子网淹没,默认网关,IP等信息. 2. 查看本机开放的端口,即已被占用的端口号. 命令: netsta ...

  3. putty实现自动登录的方法(ssh和ssh2)

    介绍putty实现自动登录的方法.   1.登录主机并输入ssh-keygen -t rsa  提示Enter file in which to save the key (/root/.ssh/id ...

  4. PHP学习笔记(1) - 开发环境搭建

    运行环境:phpstudy 它基本包括运行php应用需要的一切,php. apache.mysql,一键傻瓜安装 装好之后只需要配置虚拟主机和修改host文件就可以支持多站点 下载: http://w ...

  5. 用 BPL 封装数据连接

    BPL 代码: uDM.pas unit uDM; interface uses SysUtils, Classes, uIntf, DB, ABSMain; type TDM = class(TDa ...

  6. oracle学习总结

    set linesize 120 set pagesize 20 column file_name format a8 v$nls_parameters 数据字典中的一个表 关于null的注意: 1: ...

  7. emctl start dbconsole OC4J_dbconsole*** not found

    C:\windows\system32>emctl start dbconsole OC4J Configuration issue. D:\app\product\\db_1/oc4j/j2e ...

  8. struts2用了哪几种模式

    代理模式 责任连模式 ActionVacation 迭代模式

  9. poj 2828 Buy Tickets (线段树(排队插入后输出序列))

    http://poj.org/problem?id=2828 Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissio ...

  10. 使用PyInstaller打包Python程序

    本文转载自: http://www.pycoding.com/2015/04/23/pyinstaller.html