Richfaces 4.1 push without JMS?

百般思念 提交于 2019-12-11 21:12:46

问题


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.

Without JMS seems to be a lot simpler :)

Any suggestions?

Thanks, Milo van der Zee


回答1:


From the Richfaces 4.1 Component Reference:

3.8.6. Using Push without JMS

Since JMS coupling may be unwanted in certain cases, RichFaces provides a switch to turn off the JMS integration:

<context-param>
    <param-name>org.richfaces.push.jms.disable</param-name>
    <param-value>true</param-value>
</context-param>

Just add the above context param to your web.xml use the push component without JMS.




回答2:


try RichFaces 4.1 Component Reference again, there are two samples of usage (TopicsContext and CDI):

http://docs.jboss.org/richfaces/latest_4_X/Component_Reference/en-US/html/chap-Component_Reference-Actions.html#sect-Component_Reference-a4jpush-Using_TopicsContext_to_publish_message




回答3:


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

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

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>

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>

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.



来源:https://stackoverflow.com/questions/8836405/richfaces-4-1-push-without-jms

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