如何将事件分发到(Wildfly)群集中的所有节点? [英] How to distribute an event to all nodes in a (Wildfly) cluster?

查看:170
本文介绍了如何将事件分发到(Wildfly)群集中的所有节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在我的 JavaEE 7 WebApp中更长时间运行的进程的状态发生更改时通知群集中的所有节点,以便每个节点都可以通知他们客户通过WebSocket了解这一变化。

I would like to notify all nodes in a cluster when the state of a longer running process in my JavaEE 7 WebApp changes, so that every node can in turn notify their clients via WebSocket about that change.

我在群集环境中使用Wildfly 10。

I am working with Wildfly 10 in a clustered environment.

什么 JavaEE 7 API /编程模型或Wildfly服务是今天实现这一目标的最佳实践?

What JavaEE 7 API / Programming model or Wildfly Service would be todays best practice to achieve that ?

推荐答案

如果你想留在JavaEE生态系统中,那么JMS主题就是你要走的路。主题就像广播频道 - 订阅它的每个消息收听者都将获得此消息的副本。在wildfly集群/域中,您需要启用JMS(使用完整配置文件或手动添加消息传递子系统),然后启用集群消息传递,最后创建一个jms主题,通知客户端将在其中写入消息。您可以在官方wildfly快速入门回购中找到完整的示例 - 看看 helloworld-mdb messaging-clustering 模块。

你也可以使用在java env之外运行的专用PubSub服务,让你的应用程序为某个特定事件(例如Redis或Apache camel,...)创建订阅者,但Wildfly中的消息传递很简单,适用于大多数用例。

If you want to stay within JavaEE ecosystem, then JMS topic is the way to go. Topics are like broadcast channels - every message listener subscribed to it will get a copy of this message. In wildfly cluster/domain, you need to have JMS enabled(either use full profile or manually add messaging subsystem), then enable clustered messaging and finally create a jms topic, where your notification client will write a message to. You can find a complete example in official wildfly quickstart repo - have a look at helloworld-mdb and messaging-clustering modules.
You can also use a dedicated PubSub service running outside your java env and let your app create a subscriber to some specific event(e.g. Redis, or Apache camel,..) but messaging in Wildfly is simple and works fine for most use cases.

这篇关于如何将事件分发到(Wildfly)群集中的所有节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆