SlideShare a Scribd company logo
1 of 27
---技术分享---
        基于VM的事件驱动架构的实现
                yi.chen@qunar.com
                nereus.chen@gmail.com
                2011-11-11
相关背景
  开源项目
  1. Apache Camel
  2. Apache Spring Integration


  本项目的目标
  1.基于Spring Integration的core包进行改造
  2.轻量级化(NoSpring,less-3rd.jar)
  3.添加新特性

  项目地址
  https://github.com/nereuschen/eda-components



                       www.qunar.com
基于VM的事件驱动框架的实现

 概念


 设计思路


 代码结构


 实例




            www.qunar.com
基于VM的事件驱动框架的实现

 概念


 设计思路


 代码结构


 实例




            www.qunar.com
基于VM的事件驱动框架的实现----概念

 EDA(Event Driven-Architecture)的优势




                      www.qunar.com
基于VM的事件驱动框架的实现----概念


概念模型




             www.qunar.com
基于VM的事件驱动框架的实现----概念
  Message




  MessageBuilder




                   www.qunar.com
基于VM的事件驱动框架的实现----概念

PollableChannel(点对点)




 SubscribableChannel(发布/订阅)




                 www.qunar.com
逻辑组件




       www.qunar.com
以消息为中心




         www.qunar.com
基于VM的事件驱动框架的实现

 概念


 设计思路


 代码结构


 实例




            www.qunar.com
基于VM的事件驱动框架的实现----设计思路

 Message
 public interface Message<T> {
        T getPayload();
        MessageHeaders getHeaders();
 }

 MessageBuilder

 Message<String> message = MessageBuilder.withPayload("test")
                           .setHeader("foo", "bar") .build();




                        www.qunar.com
基于VM的事件驱动框架的实现----设计思路

MessageChannel        method            implement
PollableChannel       send()            QueueChannel
                      receive()
SubscribableChannel   send()            DirectChannel
                      subscribe()       ExecutorChannel
                      unsubscribe()     PublishSubscribeChannel




                        www.qunar.com
基于VM的事件驱动框架的实现----设计思路

  QueueChannel




                 www.qunar.com
基于VM的事件驱动框架的实现----设计思路

  DirectChannel




                  www.qunar.com
基于VM的事件驱动框架的实现----设计思路

  ExecutorChannel




                    www.qunar.com
基于VM的事件驱动框架的实现----设计思路

  PublishSubscribeChannel




                   www.qunar.com
基于VM的事件驱动框架的实现----设计思路

选择不同类型channel需要考虑的因素




              www.qunar.com
基于VM的事件驱动框架的实现

 概念


 设计思路


 代码结构


 实例




            www.qunar.com
基于VM的事件驱动框架的实现----代码结构




             www.qunar.com
基于VM的事件驱动框架的实现----序列图




             www.qunar.com
基于VM的事件驱动框架的实现----序列图




             www.qunar.com
基于VM的事件驱动框架的实现----序列图




             www.qunar.com
基于VM的事件驱动框架的实现

 概念


 设计思路


 代码结构


 实例




            www.qunar.com
基于VM的事件驱动框架的实现----实例
QueueChannel queueChannel = new QueueChannel();
// register the queueChannel
ChannelRegistry.registerMessageChannel(channelName,queueChannel);
// build a new message
Message<String> message = MessageBuilder.withPayload("this is a message")
                                      .setHeader("headerA", "headerValue").build();
// send a message to the queueChannel
queueChannel.send(message);


 // lookup the queueChannl,may be an empty channel before the registried
QueueChannel queueChannel = ChannelRegistry.lookupQueueChannel(channelName);
// blocking until there is a message
Message message = queueChannel.receive();
System.out.println("Received message : " + message.toString());




                                  www.qunar.com
基于VM的事件驱动框架的实现----实例


项目实例

https://github.com/nereuschen/eda-components/tree/
master/src/test/java/com/nereuschen/eda/demo




                        www.qunar.com
thanks!

More Related Content

What's hot

快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)
快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)
快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)Will Huang
 
Angular 4 新手入門攻略完全制霸
Angular 4 新手入門攻略完全制霸Angular 4 新手入門攻略完全制霸
Angular 4 新手入門攻略完全制霸Will Huang
 
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例Will Huang
 
ASP.NET 5 的創新與變革
ASP.NET 5 的創新與變革ASP.NET 5 的創新與變革
ASP.NET 5 的創新與變革Will Huang
 
Frontend Devops at Cloudinsight
Frontend Devops at CloudinsightFrontend Devops at Cloudinsight
Frontend Devops at CloudinsightYan Wang
 
twMVC#19 | opserver監控服務的解決
twMVC#19 | opserver監控服務的解決twMVC#19 | opserver監控服務的解決
twMVC#19 | opserver監控服務的解決twMVC
 
Node.js在淘宝的应用实践
Node.js在淘宝的应用实践Node.js在淘宝的应用实践
Node.js在淘宝的应用实践taobao.com
 
SignalR實戰技巧 twmvc#17
SignalR實戰技巧 twmvc#17 SignalR實戰技巧 twmvc#17
SignalR實戰技巧 twmvc#17 twMVC
 
Nginx使用和模块开发
Nginx使用和模块开发Nginx使用和模块开发
Nginx使用和模块开发qingpiao1983
 
Asp.net mvc 6 新功能初探
Asp.net mvc 6 新功能初探Asp.net mvc 6 新功能初探
Asp.net mvc 6 新功能初探Gelis Wu
 
AKS 與開發人員體驗 (Kubernetes 大講堂)
AKS 與開發人員體驗 (Kubernetes 大講堂)AKS 與開發人員體驗 (Kubernetes 大講堂)
AKS 與開發人員體驗 (Kubernetes 大講堂)Will Huang
 
ASP.NET 5 快速入門 (Getting Started ASP.NET 5)
ASP.NET 5 快速入門 (Getting Started ASP.NET 5)ASP.NET 5 快速入門 (Getting Started ASP.NET 5)
ASP.NET 5 快速入門 (Getting Started ASP.NET 5)Jeff Chu
 
Entity framework + Linq 介紹
Entity framework + Linq 介紹Entity framework + Linq 介紹
Entity framework + Linq 介紹Alan Tsai
 
KSDG-ASP.NET MVC 5 Overview (偽三國誌)
KSDG-ASP.NET MVC 5 Overview (偽三國誌)KSDG-ASP.NET MVC 5 Overview (偽三國誌)
KSDG-ASP.NET MVC 5 Overview (偽三國誌)Bruce Chen
 
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山imShining @DevCamp
 
RxJS 6 新手入門
RxJS 6 新手入門RxJS 6 新手入門
RxJS 6 新手入門Will Huang
 
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐twMVC
 
使用 ASP.NET 5 實戰開發雲端應用程式
使用 ASP.NET 5 實戰開發雲端應用程式使用 ASP.NET 5 實戰開發雲端應用程式
使用 ASP.NET 5 實戰開發雲端應用程式Will Huang
 
Maven技术分享
Maven技术分享Maven技术分享
Maven技术分享wslfh2005
 
DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略Will Huang
 

What's hot (20)

快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)
快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)
快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)
 
Angular 4 新手入門攻略完全制霸
Angular 4 新手入門攻略完全制霸Angular 4 新手入門攻略完全制霸
Angular 4 新手入門攻略完全制霸
 
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
 
ASP.NET 5 的創新與變革
ASP.NET 5 的創新與變革ASP.NET 5 的創新與變革
ASP.NET 5 的創新與變革
 
Frontend Devops at Cloudinsight
Frontend Devops at CloudinsightFrontend Devops at Cloudinsight
Frontend Devops at Cloudinsight
 
twMVC#19 | opserver監控服務的解決
twMVC#19 | opserver監控服務的解決twMVC#19 | opserver監控服務的解決
twMVC#19 | opserver監控服務的解決
 
Node.js在淘宝的应用实践
Node.js在淘宝的应用实践Node.js在淘宝的应用实践
Node.js在淘宝的应用实践
 
SignalR實戰技巧 twmvc#17
SignalR實戰技巧 twmvc#17 SignalR實戰技巧 twmvc#17
SignalR實戰技巧 twmvc#17
 
Nginx使用和模块开发
Nginx使用和模块开发Nginx使用和模块开发
Nginx使用和模块开发
 
Asp.net mvc 6 新功能初探
Asp.net mvc 6 新功能初探Asp.net mvc 6 新功能初探
Asp.net mvc 6 新功能初探
 
AKS 與開發人員體驗 (Kubernetes 大講堂)
AKS 與開發人員體驗 (Kubernetes 大講堂)AKS 與開發人員體驗 (Kubernetes 大講堂)
AKS 與開發人員體驗 (Kubernetes 大講堂)
 
ASP.NET 5 快速入門 (Getting Started ASP.NET 5)
ASP.NET 5 快速入門 (Getting Started ASP.NET 5)ASP.NET 5 快速入門 (Getting Started ASP.NET 5)
ASP.NET 5 快速入門 (Getting Started ASP.NET 5)
 
Entity framework + Linq 介紹
Entity framework + Linq 介紹Entity framework + Linq 介紹
Entity framework + Linq 介紹
 
KSDG-ASP.NET MVC 5 Overview (偽三國誌)
KSDG-ASP.NET MVC 5 Overview (偽三國誌)KSDG-ASP.NET MVC 5 Overview (偽三國誌)
KSDG-ASP.NET MVC 5 Overview (偽三國誌)
 
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山
 
RxJS 6 新手入門
RxJS 6 新手入門RxJS 6 新手入門
RxJS 6 新手入門
 
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
 
使用 ASP.NET 5 實戰開發雲端應用程式
使用 ASP.NET 5 實戰開發雲端應用程式使用 ASP.NET 5 實戰開發雲端應用程式
使用 ASP.NET 5 實戰開發雲端應用程式
 
Maven技术分享
Maven技术分享Maven技术分享
Maven技术分享
 
DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略
 

Similar to 基于Vm的事件驱动架构的实现

ASP.NET Core 2.1設計新思維與新發展
ASP.NET  Core 2.1設計新思維與新發展ASP.NET  Core 2.1設計新思維與新發展
ASP.NET Core 2.1設計新思維與新發展江華 奚
 
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016Jeff Chu
 
Real World ASP.NET MVC
Real World ASP.NET MVCReal World ASP.NET MVC
Real World ASP.NET MVCjeffz
 
Asp.net 5 新功能與變革
Asp.net 5 新功能與變革Asp.net 5 新功能與變革
Asp.net 5 新功能與變革Gelis Wu
 
ASP.Net MVC2 简介
ASP.Net MVC2 简介ASP.Net MVC2 简介
ASP.Net MVC2 简介Allen Lsy
 
Eucalyptus安装及实例映像制作
Eucalyptus安装及实例映像制作Eucalyptus安装及实例映像制作
Eucalyptus安装及实例映像制作liangxiao0315
 
Top100summit automan x之框架介绍 王超
Top100summit automan x之框架介绍 王超Top100summit automan x之框架介绍 王超
Top100summit automan x之框架介绍 王超drewz lin
 
twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC#01 | ASP.NET MVC 的第一次親密接觸twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC#01 | ASP.NET MVC 的第一次親密接觸twMVC
 
Flex 4.5 action custom component development
Flex 4.5 action custom component developmentFlex 4.5 action custom component development
Flex 4.5 action custom component developmentjexchan
 
建站大业,实战ASP.NET 4
建站大业,实战ASP.NET 4建站大业,实战ASP.NET 4
建站大业,实战ASP.NET 4Cat Chen
 
Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有Wade Huang
 
方建国 -V mware-ha实战1
方建国 -V mware-ha实战1方建国 -V mware-ha实战1
方建国 -V mware-ha实战1landece
 
从网格计算到云计算
从网格计算到云计算从网格计算到云计算
从网格计算到云计算Riquelme624
 
Beyond rails server
Beyond rails serverBeyond rails server
Beyond rails serverMichael Chen
 
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit TestingASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing江華 奚
 
twMVC#30 | 你應該瞭解的 container-on-azure-二三事
twMVC#30 | 你應該瞭解的 container-on-azure-二三事twMVC#30 | 你應該瞭解的 container-on-azure-二三事
twMVC#30 | 你應該瞭解的 container-on-azure-二三事twMVC
 
VCACICM6_M05_Blueprints_and_Catalog Services.pptx
VCACICM6_M05_Blueprints_and_Catalog Services.pptxVCACICM6_M05_Blueprints_and_Catalog Services.pptx
VCACICM6_M05_Blueprints_and_Catalog Services.pptxLoessPlateau
 
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)twMVC
 

Similar to 基于Vm的事件驱动架构的实现 (20)

ASP.NET Core 2.1設計新思維與新發展
ASP.NET  Core 2.1設計新思維與新發展ASP.NET  Core 2.1設計新思維與新發展
ASP.NET Core 2.1設計新思維與新發展
 
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
 
Real World ASP.NET MVC
Real World ASP.NET MVCReal World ASP.NET MVC
Real World ASP.NET MVC
 
Asp.net 5 新功能與變革
Asp.net 5 新功能與變革Asp.net 5 新功能與變革
Asp.net 5 新功能與變革
 
ASP.Net MVC2 简介
ASP.Net MVC2 简介ASP.Net MVC2 简介
ASP.Net MVC2 简介
 
Eucalyptus安装及实例映像制作
Eucalyptus安装及实例映像制作Eucalyptus安装及实例映像制作
Eucalyptus安装及实例映像制作
 
Hp云管理平台3.0
Hp云管理平台3.0Hp云管理平台3.0
Hp云管理平台3.0
 
Top100summit automan x之框架介绍 王超
Top100summit automan x之框架介绍 王超Top100summit automan x之框架介绍 王超
Top100summit automan x之框架介绍 王超
 
twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC#01 | ASP.NET MVC 的第一次親密接觸twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC#01 | ASP.NET MVC 的第一次親密接觸
 
Hyper V Final
Hyper  V FinalHyper  V Final
Hyper V Final
 
Flex 4.5 action custom component development
Flex 4.5 action custom component developmentFlex 4.5 action custom component development
Flex 4.5 action custom component development
 
建站大业,实战ASP.NET 4
建站大业,实战ASP.NET 4建站大业,实战ASP.NET 4
建站大业,实战ASP.NET 4
 
Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有
 
方建国 -V mware-ha实战1
方建国 -V mware-ha实战1方建国 -V mware-ha实战1
方建国 -V mware-ha实战1
 
从网格计算到云计算
从网格计算到云计算从网格计算到云计算
从网格计算到云计算
 
Beyond rails server
Beyond rails serverBeyond rails server
Beyond rails server
 
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit TestingASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
 
twMVC#30 | 你應該瞭解的 container-on-azure-二三事
twMVC#30 | 你應該瞭解的 container-on-azure-二三事twMVC#30 | 你應該瞭解的 container-on-azure-二三事
twMVC#30 | 你應該瞭解的 container-on-azure-二三事
 
VCACICM6_M05_Blueprints_and_Catalog Services.pptx
VCACICM6_M05_Blueprints_and_Catalog Services.pptxVCACICM6_M05_Blueprints_and_Catalog Services.pptx
VCACICM6_M05_Blueprints_and_Catalog Services.pptx
 
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
 

基于Vm的事件驱动架构的实现