Weld - 异步事件观察者
我正在使用 Weld 来观察事件。我认为有一种方法可以指定观察者是否异步,但我没有找到该注释或文档。
观察者可以异步吗?如果可以,我需要做什么才能实现这一点?
I am using Weld to observe events. I thought there was a way to specify if the observer was asynchronous or not, but I am not finding that annotation or documentation.
Can observers be asynchronous, if so, what do I need to do to make that happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有一个对此的公开请求:CDI-31:异步事件。
根据您的要求,您可以按照评论中的指示设置不同的 事务观察器:如果您使用 AFTER_COMPLETION 或 AFTER_SUCCESS,它在您的应用程序中应该看起来像是异步执行。然而,在框架解决之前,我刚刚找到了一个使用 用于 CDI 中异步执行的 JMS。
There is an open request for this: CDI-31: Asynchronous events.
Depending on your requirements, you can, as indicated in your comment, set a different transactional observer: If you use AFTER_COMPLETION or AFTER_SUCCESS, it should seem to your application like an asynchronous execution. However until a framework solves , I have just found an example using JMS for asynchronous execution in CDI.
查看 Piotr Nowicki 博客 http://piotrnowicki.com/2013/05/asynchronous-cdi-events/
他描述了几种实现 CDI 异步行为的方法事件。
Take a look at post on Piotr Nowicki's blog http://piotrnowicki.com/2013/05/asynchronous-cdi-events/
He described a couple of methods for achieving asynchronous behavior of CDI events.
如果你们想看到这种情况发生,您需要访问 Kariem 的答案中提供的链接并表达您的意见。专家组似乎不愿意考虑添加异步事件,因为他们认为这会使规范变得臃肿。
老实说,Guice 设法提供了这个功能,而且它仍然是轻量级的,所以我发现反对这个小反直觉的论点。不过,如果您想查看此功能,请前往链接,表达您的意见。
-乔纳森
If you guys want to see this happen, you'll need to head over the the link provided in Kariem's answer and voice your opinion. It seems the expert group is unwilling to consider adding async events because they consider it bloating the spec.
Honestly, Guice manages to offer this feature, and it remains lightweight, so I find the argument against this little counter-intuitive. Nevertheless, if you want to see this feature, head to the link, voice your opinion.
-Jonathan