NEsper事件处理 z
http://esper.codehaus.org/nesper/documentation/documentation.html
环境配置
- NEsper库下载:下载网址
- Vs2010环境集成
在项目中添加下载的dll文件下的库即可。
- Demo展示
事件类:
- 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;
- }
- }
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;
}
}
事件发送类
- 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();
- }
- }
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();
}
}
事件监听类
- 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();
- }
- }
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---object event example
- send shirt:74.50
- sumPrice:74.5
- received: shirt:74.5
- send shoes:60.50
- sumPrice:135
- received: shoes:60.5
- send coat:70.50
- sumPrice:131
- received: coat:70.5
NEsper事件处理 z的更多相关文章
- 【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 ...
- 事件流处理框架NEsper for .NET z
复合事件处理(Complex Event Processing)介绍提到了开源的Esper,NEsper 是一个事件流处理(Event Stream Processing,ESP)和复杂事件处理(Co ...
- NEsper z
对实时信息分析和处理,常常需要客户应用程序的开发相应功能.一般地,这些功能需要提供以下的处理流程,分析获取的数据,筛选数据,提取出有用的信息,然后将其通过特定的形式展现出来.由于具体实时信息的高并发性 ...
- NESPER的大体结构 z
NEsper从内容上分为两块,NEsper的核心NEsper.dll和NEsper.IO.dll. (1)NEsper的核心包包含了EPL语法解析引擎,事件监听机制,事件处理等核心模块. (2)NEs ...
- NEsper使用的事件类型 z
NEsper使用的事件类型来描述事件的类型信息.你的应用在启动时可能预先配置定义事件类型,或者在运行时通过API或EPL语法动态的增加事件类型. EPL中的create schema 的语法允许在运行 ...
- NEsper Nuget包
Esper是专门进行复杂事件处理(CEP)的流处理平台,Java版本为Esper,.Net版本为NEsper.Esper & NEsper可以方便开发者快速开发部署处理大容量消息和事件的应用系 ...
- Qt Quick鼠标事件处理、键盘、计时器
在<Qt Quick 事件处理之信号与槽>中介绍了 QML 中怎样使用内建类型的信号以及怎样自己定义信号,这次我们来看看怎样处理鼠标.键盘.定时器等事件.这些时间在处理时,一般是通过信号来 ...
- Microsoft .Net Remoting系列专题之三:Remoting事件处理全接触
前言:在Remoting中处理事件其实并不复杂,但其中有些技巧需要你去挖掘出来.正是这些技巧,仿佛森严的壁垒,让许多人望而生畏,或者是不知所谓,最后放弃了事件在Remoting的使用.关于这个主题,在 ...
- 【转】Microsoft .Net Remoting之Remoting事件处理全接触
Remoting事件处理全接触 前言:在Remoting中处理事件其实并不复杂,但其中有些技巧需要你去挖掘出来.正是这些技巧,仿佛森严的壁垒,让许多人望而生畏,或者是不知所谓,最后放弃了事件在Remo ...
随机推荐
- SQL Server 2012 读写分离设置
SQL Server 2012 读写分离设置 - AlsoIn 时间 2014-07-21 17:38:00 博客园-所有随笔区 原文 http://www.cnblogs.com/also/p/ ...
- 查找计算机IP及占用端口
1. 在电脑启动搜索框,输入cmd回车打开命令提示符窗口. 输入ipconfig,就可以查看电脑的子网淹没,默认网关,IP等信息. 2. 查看本机开放的端口,即已被占用的端口号. 命令: netsta ...
- putty实现自动登录的方法(ssh和ssh2)
介绍putty实现自动登录的方法. 1.登录主机并输入ssh-keygen -t rsa 提示Enter file in which to save the key (/root/.ssh/id ...
- PHP学习笔记(1) - 开发环境搭建
运行环境:phpstudy 它基本包括运行php应用需要的一切,php. apache.mysql,一键傻瓜安装 装好之后只需要配置虚拟主机和修改host文件就可以支持多站点 下载: http://w ...
- 用 BPL 封装数据连接
BPL 代码: uDM.pas unit uDM; interface uses SysUtils, Classes, uIntf, DB, ABSMain; type TDM = class(TDa ...
- oracle学习总结
set linesize 120 set pagesize 20 column file_name format a8 v$nls_parameters 数据字典中的一个表 关于null的注意: 1: ...
- emctl start dbconsole OC4J_dbconsole*** not found
C:\windows\system32>emctl start dbconsole OC4J Configuration issue. D:\app\product\\db_1/oc4j/j2e ...
- struts2用了哪几种模式
代理模式 责任连模式 ActionVacation 迭代模式
- poj 2828 Buy Tickets (线段树(排队插入后输出序列))
http://poj.org/problem?id=2828 Buy Tickets Time Limit: 4000MS Memory Limit: 65536K Total Submissio ...
- 使用PyInstaller打包Python程序
本文转载自: http://www.pycoding.com/2015/04/23/pyinstaller.html