Vert.x事件总线与CDI事件之间的区别

发布于 2025-01-21 22:34:57 字数 348 浏览 3 评论 0原文

使用 @observes使用CDI事件发布事件总线与使用CDI事件发布事件有什么区别?

我目前正在使用Quarkus的所有异步通信的活动总线。由于Vert.x事件总线不支持Quarkus中的群集通信( https://github.com /quarkusio/quarkus/esseage/10889 ),我对本地事件发布表示同意。但是,在什么情况下,人们会选择参加CDI事件而不是使用EventBus?

What is the difference between using an event bus for publishing events vs using CDI Event with @Observes?

I'm currently using the event bus for all async communications in Quarkus. Since the vert.x event bus does not support cluster communication in Quarkus (https://github.com/quarkusio/quarkus/issues/10889), I'm ok with local event publishing. However, in what cases would one choose to go with a CDI event instead of using the eventbus?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋凉 2025-01-28 22:34:57

CDI事件发生“线程”,这意味着事件触发线程在观察者上调用一个未知号码(可能为0)可能是100。射击线。
在此处阅读详细信息: https://wwwww.baeldung.com/cdi-event-notification

可能与vert.x不同,哪些事件可能会在新线程中触发,或者可能在同一线程中发射。这仅取决于您如何编写和配置程序。如果您有一个群集的Vert.x应用程序,则它们肯定在另一个群集成员上启动时将在不同的线程中启动。

对您情况的正确答案取决于您要解决的问题。

CDI Events occur "in thread", meaning essentially the event firing thread calls an unknown number over observers, which may be 0, may be 100. The key here is observers always run in the same thread as the firing thread.
Read the details here: https://www.baeldung.com/cdi-event-notification

That may differ with Vert.x, which events may fire in new threads, or may fire in the same thread. This depends solely on how you write and configure your program. If you have a clustered Vert.x app, they definitely are firing in different threads if they launch on another cluster member.

The correct answer for your situation depends on the problem you're trying to solve.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文