本文介绍了Richfaces 4.1 推送没有 JMS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 RF3.2 分支中使用了 a4j:push 但对于 RF4.1,它似乎有点复杂.特别是对 JMS 系统的需求是需要研究的.在学习时,我读到不再需要 JMS,但我找不到任何演示.我在夜间构建中找到了操作方法和演示代码,但它们似乎都使用 JMS.

I used a4j:push in the RF3.2 branch but with RF4.1 it seems to be a bit more complicated. Esspecially the demand for a JMS system is something that needs some studying. While studying I read that JMS is no longer needed but I can't find any demo's. I located the how-to and the demo code in the nightly build but they all seem to use JMS.

没有 JMS 似乎简单很多 :)

Without JMS seems to be a lot simpler :)

有什么建议吗?

谢谢,米洛·范德泽

推荐答案

我知道这个帖子是旧帖子,但我可以看到这个帖子是这个话题的热门搜索之一.

I know this post is an old post, but I can see that this thread is one of the top search for this topic.

如果您使用的是 Servlet 3.0,则不需要对 web.xml 进行任何更改.

If you are using Servlet 3.0, no changes in web.xml is required.

首先,您需要使用正确的版本安装大气.我从事的项目使用的是 Richfaces 4.3.6.Final.它兼容的大气版本是1.0.17.

First, you need to install atmosphere with the right version. The project that I have worked on is using Richfaces 4.3.6.Final. The version of atmosphere it is compatible is 1.0.17.

<dependency>
    <groupId>org.atmosphere</groupId>
    <artifactId>atmosphere-runtime</artifactId>
    <version>1.0.17</version>
</dependency>

然后您可以开始使用 TopicContext 从托管 bean 向订阅者发送通知.这是我将数据发布到 TopicContext 的方式.

Then you can start using the TopicContext to send notification to the subscribers from the managed bean. Here is how I publish data to the TopicContext.

TopicKey topicKey = new TopicKey("sometopic");
TopicsContext topicsContext = TopicsContext.lookup();

try {
    topicsContext.publish(topicKey, "somenewdata");
} catch (MessageException e) {
    e.printStackTrace();
}

然后您只需要在订阅页面中包含推送组件.

Then you simply need include the push component in the subscribing page.

<a4j:push address="sometopic">
    <a4j:ajax event="dataavailable" oncomplete="someJsMethodToExecuteAfterGettingNotified();"/>
</a4j:push>

设置成功后,您只需在托管 bean 中的任何位置调用 TopicContext#publish,即可自动通知订阅该主题的页面.

Once the setup is success, you can simply call TopicContext#publish anywhere in the managed bean so that the pages that are subscribing to the topic will be automatically notified.

这篇关于Richfaces 4.1 推送没有 JMS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 19:55
查看更多