How to distribute an event to all nodes in a (Wildfly) cluster?

岁酱吖の 提交于 2019-12-24 03:08:25

问题


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.

I am working with Wildfly 10 in a clustered environment.

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


回答1:


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.



来源:https://stackoverflow.com/questions/44454512/how-to-distribute-an-event-to-all-nodes-in-a-wildfly-cluster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!