[weld] 【转】Decoupling event producers and event consumers in Java EE 6 using CDI and JMS
wuhaixing
2010-04-19
http://djnweb2.sjc.collab.net/blog/209941
There is however another, more subtle, form of coupling taking place: event dispatching usually happens in the same thread that fired the event. Event observers can perform some long-running tasks upon receiving an event, which will block this thread. This may or may not be a problem, depending on where the event proucer thread is located. If this thread is for instance a GUI event thread or a HTTP request processing thread then the end user may be forced to wait for a response from the application while a slow operation is taking place. To solve this problem it would be nice to be able to process the events in a backhround thread. Unfortunately, the current CDI specification lacks such a feature. There are many ways to work around this problem. The one I will present here involves creating a generic background event processing framework that can be used to process any application event in background using JMS as a dispatch mechanism. The Idea is to change the event processing wokflow from: Event Producer -> Event Consumer(s) [foreground thread] To: Event Producer -> Event Sender -> JMS Queue [foreground thread] JMS Queue -> Event Dispatcher -> Event Consumer [background thread] |
相关讨论
相关资源推荐
- C# MES通信从入门到精通(9)——c#使用visual studio2019社区版部署webservice服务
- vs.net中文教程
- C# 超详细的WebService创建、发布与调用(VS2022)
- 更改web service地址
- Visual C#.NET Web服务开发实战指南
- asp.net网站服务器,vs2010制作简单的asp.net网站
- VS2017创建WebAPI分层项目(2)——Dao层和Service创建
- Visual Studio2010调用WebService步骤
- VS code 如何编译运行web项目教程
- Visual Studio Code介绍——调试Web项目