Help

Overview

RichFaces Push allows you to perform realtime client side updates triggered via events from the server side. We integrate with the Atmosphere framework which provides various transport mechanisms according to concrete browser support(Comet, HTML5 WebSockets). On the server events are managed by integrating Java Messaging Service (JMS). This provide enterprise level messaging integration all the way to the browser!

In this blog I will describe our irc-client example application that was created to introduce the RichFaces push features. It provides the following functionality:

  • Connect to the freenode.org IRC server
  • Join a channel with choosen nickname
  • Receive all channel messages (nick change, join, part...)
  • Send messages to the channel
  • Observe the list of joined users with real-time updates

In this blog I'm only going to review the important configuration, and source code snippets from the application. The full source code can be checked out from SVN so you can try it for yourself. Instructions for building and deploying the application is in the readme.txt.

Dependencies

To save time with application setup I have created a starter application using richfaces-archetype-simpleapp archetype. Next we need to update application pom.xml to add Atmosphere fremework dependency. For the client side a4j:push uses jquery-atmosphere.js plugin (added implicitly by the component renderer).

NOTE: that particular sample targeted for JBoss 6 Application Server. So we will use JBoss HornetQ available out of the box. Using RichFaces Push under Tomcat or Jetty requires additional JMS dependencies and configuration code. We will work on maven profiles and additional optional classes for that case also in future releases. At the moment the only place to review that configuration is with our developer demo which configured for tomcat using external HornetQ dependencies and configuration class for its initialization.

We need to add the atmosphere-runtime to the pom.xml. This is only needed if you are using the push component.

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

Also as the demo shown there provides simple IRC client we added one more dependency:

<dependency>
    <groupId>pircbot</groupId>
    <artifactId>pircbot</artifactId>
    <version>1.4.2</version>
</dependency>

PircBot is a simple framework for writing IRC bots.

Configuring JMS

Lets first discuss why we need JMS at all? Why not just use for example push context object? The answer is pretty straightforward. Usage of JMS at the back-end provides excellent integration with EE containers, and advanced messaging services. It also frees you from managing various entities at your business layer. If you are already using JMS for messaging in your application - you will just continue to send the same messages and you just need to to declare a4j:push at views which should listen that topics.

We assume that you're familiar with JMS so will not provide details here. To learn more about it visit JMS documentation.

Now it is time to configure JMS for our example. We will use JBoss 6 AS for application deployment as mentioned in dependencies section. So we'll use JMS server bundled with JBoss AS. We need to create topics which will be used by Push to check for the messages. Let's start JBoss 6 AS and open http://localhost:8080/admin-console. We will use default admin/admin credentials to log-in. Then click the JMS topics in navigation menu and create new JMS topic with the following settings:

Name: chat

JNDI name: /topic/chat All the others: by default.

In the same form we need to add roles for that topic. For that demo application we will create single role with next parameters:

Name: guest

Send: yes

Consume: yes

create subscriber: yes

delete subscriber: yes

create durable subscriber: yes

delete durable subscriber: yes

IMPORTANT: The last two options are critical for push functionality as we using durable subscriptions in order to be able to receive all the events including ones which were sent while the push was not connected to the server. So if they are set to false - push will not be able to register subscribers.

So here is what you should see after JMS setting done:

That's all. Now we are ready with JMS configuration.

NOTE: if you not familiar with JBoss configuration using admin-console visit JBoss AS Administration Console User Guide.

Web Application Configuration

Now let's add application settings required by RichFaces Push. We need an additional filter and a few context-param's to be added. Here is what we used for that demo application:

<context-param>
    <param-name>org.richfaces.push.jms.connectionUsername</param-name>
    <param-value>guest</param-value>
</context-param>
<context-param>
    <param-name>org.richfaces.push.jms.connectionPassword</param-name>
    <param-value>guest</param-value>
</context-param>
<filter>
    <filter-name>PushFilter</filter-name>
    <filter-class>org.richfaces.webapp.PushFilter</filter-class>
    <async-supported>true</async-supported>
</filter>
<filter-mapping>
    <filter-name>PushFilter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

Let's review those parameters in details. At first we need the PushFilter to be installed and mapped to Faces Servlet. It will handle the push request and serve event using the Atmosphere runtime. And connectionUserName and connectionPassword context parameters are needed in order to defined the credentials used to work with JMS for connecting and subscribing to topics.

Here is the table with all the parameters which could be used in your application:

context-param Name Default value Description
org.richfaces.push.jms.connectionFactory /ConnectionFactory JMS connection factory JNDI name
org.richfaces.push.jms.topicsNamespace /topic used as a root name from which all topics are resolved: i.e. 'chat' topic by default will be looked up via /topics/chat JNDI name.
org.richfaces.push.jms.connectionUsername - Username used for connection and topics creation/listening
org.richfaces.push.jms.connectionPassword - Password used for connection and topics creation/listening

Note: there are also JNDI references to credentials strings available:

  • java:comp/env/org.richfaces.push.jms.connectionUsername
  • java:comp/env/org.richfaces.push.jms.connectionPassword

An alternative to using web.xml definitions is to provide all the parameters using properties file org/richfaces/push.properties.

TopicsContext initialization

Now we need to initialize org.richfaces.application.push.TopicsContext with the JMS topics we will listen for. For this purpose we created a JSF 2 System Event listener which handles PostConstructApplicationEvent:

public class TopicsInitializer implements SystemEventListener {
   public void processEvent(SystemEvent event) throws AbortProcessingException {
       TopicsContext topicsContext = TopicsContext.lookup();
       Topic topic = topicsContext.getOrCreateTopic(new TopicKey("chat"));
       topic.setMessageDataSerializer(DefaultMessageDataSerializer.instance());
       topic.addTopicListener(new SessionTopicListener() {...});
   }
  public boolean isListenerForSource(Object source) {
       return true;
   }
}

and registered it in faces-config:

<application>
    <system-event-listener>
        <system-event-listener-class>org.ircclient.listeners.TopicsInitializer</system-event-listener-class>
        <system-event-class>javax.faces.event.PostConstructApplicationEvent</system-event-class>
    </system-event-listener>
</application>

With this we have created new topic in TopicContext with chat name (the same as we defined configuring the JMS).

Actually MessageDataSerializer and TopicListener creation are optional, so let's briefly describe the main idea of these objects.

  • Messages serializer is used to serialize the message to the expected format for passing to the client. By default built-in serializer will serialize the message data to JavaScript.
  • Session topic listener is used to handle subscriptions (pre and post-processing) and unsubscription events. This could be used for example in order to check user permissions prior to connecting to some topic and perform some additional post-processing after some push component successfully attached to topics. In the sample there are just logging used so the code is omitted there.

Application Code

We are done with settings and push initialization stuff, and it's time to actually explore the example code to see how we manage the IRC connections, and how push is used for page updates according to server-side events.

Logging to IRC

This section is not directly related to Push but describes the code used for connection to IRC. Here is the simple page used:

<rich:panel header="Connect to IRC">
    <h:form>
        <rich:messages style=”color:red”/>
            <h:panelGrid columns="2">
                <h:outputText value="Your nickname:" />
                <h:inputText required="true" id="name" value="#{chatBean.userName}" />
                <h:outputText value="Channel:" />
                <h:outputText value="RichFaces" style="font-weight:bold"/>                        
                <h:outputText value="Server:" />
                <h:outputText value="irc.freenode.org" style="font-weight:bold"/>                
            </h:panelGrid>
        <h:commandButton value="Connect" action="#{chatBean.connect}" />
    </h:form>
</rich:panel>

It's rendered as:

Note that for simplicity purposes the channel and server names are using constants. In the future we plan to extend the sample with ability to open multiple channels and so on..

And here is the ChatBean.java used:

@ManagedBean
@SessionScoped
public class ChatBean extends PircBot implements Serializable {
private static final String SERVER_URL = "irc.freenode.org";
private static final int SERVER_PORT = 6667;
private static final String CHANNEL_PREFIX = "#";
private static final String SUBTOPIC_SEPARATOR = "_";
private static final String DEFAULT_CHANNEL = "richfaces";
private String channelName;
private String message;
public String connect() {
       try {
           this.connect(SERVER_URL, SERVER_PORT);
           this.joinChannel(CHANNEL_PREFIX + DEFAULT_CHANNEL);
           channelName = DEFAULT_CHANNEL;
       } catch (NickAlreadyInUseException e) {
           FacesContext.getCurrentInstance().addMessage(null,
               new FacesMessage(FacesMessage.SEVERITY_ERROR, this.getName() + " nick 
               already in use", this.getName()
               + " nick already in use"));
           return null;
       } catch (IOException e) {
           FacesContext.getCurrentInstance().addMessage(null,
               new FacesMessage(FacesMessage.SEVERITY_ERROR, "Sorry, server unresponsive. 
               Try again later.",
               "Sorry, server unresponsible. Try again later."));
           return null;
       } catch (IrcException e) {
           FacesContext.getCurrentInstance().addMessage(null,
               new FacesMessage(FacesMessage.SEVERITY_ERROR,
                   "Sorry, we encountered IRC services problems. Try again later.",
                   "Sorry, we encountered IRC services problems. Try again later."));
        return null;
       }
       return "chat";
   }
...
}

As you can see our bean extends the PirBot abstract class. So we just using PircBot api in order to get connected to server. And performing redirect to most interesting for us chat.xhtml page.

Client main page

Screenshot below shows you the result we want to achieve on that page:

Here is the complete listing of the chat.xhtml page. We'll review it in details below:

<script>
    function getMessageString(data){
        return data.author + " - " +data.timestamp+ ": " + data.text;
    }
</script>
<rich:panel header="Welcome to #{chatBean.channelName} channel at #{chatBean.serverName}" 
id="chatpanel">
    <rich:panel styleClass="chatOutput" bodyClass="#{chatBean.channelName}Output" />
    <rich:panel styleClass="chatList">
        <rich:list value="#{chatBean.users}" var="user" id="users" type="unordered">
            #{user.nick}
        </rich:list>
    </rich:panel>
    <br clear="all" />
    <hr />
    <h:form>
        <a4j:push address="#{chatBean.listSubtopic}@chat"
            onerror="alert(event.rf.data)">
            <a4j:ajax event="dataavailable" render="users" execute="@none" />
        </a4j:push>
        <a4j:push address="#{chatBean.messagesSubtopic}@chat"
            onerror="alert(event.rf.data)" ondataavailable="jQuery('&lt;div/&gt;').
            prependTo('.#{chatBean.channelName}Output').text(
            getMessageString(event.rf.data))" />
        <h:inputTextarea value="#{chatBean.message}" rows="3" style="width:80%" id="nm" />
        <a4j:commandButton value="Send" action="#{chatBean.send}" render="@none" execute="@form" />
    </h:form>
    <hr />
    <h:form>
        <rich:panel header="Change nickname:">
            <h:inputText valueChangeListener="#{chatBean.changeNick}" id="cn" />
            <a4j:commandButton value="Change" execute="@form" render="@none"/>
        </rich:panel>
        <h:commandButton value="Disconnect" action="#{chatBean.leave}"/>
    </h:form>
</rich:panel>

I will show you two options of performing push updates.

  1. Using ondataavailable JavaScript handler which will grab the data from the JMS event directly on the client.
  2. Using a4j:ajax behavior to trigger an Ajax request which will perform partial update when the push informs us about server event.

So the first panel:

<rich:panel styleClass="chatOutput" bodyClass="#{chatBean.channelName}Output" />

is just a container for the chat text which will be updated via JavaScript.

And the second panel:

<rich:panel styleClass="chatList">
    <rich:list value="#{chatBean.users}" var="user" id="users" type="unordered">
        #{user.nick}
    </rich:list>
</rich:panel>

contains the rich:list component which displays the users connected to the channel. It will be updated via an Ajax request that is triggered when the event about list change is populated at server side.

Client side updates on server-side events using JavaScript

Let's review the first a4j:push component more closely:

<a4j:push address="#{chatBean.messagesSubtopic}@chat" onerror="alert(event.rf.data)"
    ondataavailable="jQuery('&lt;div/&gt;').prependTo('.#{chatBean.channelName}Output').
    text(getMessageString(event.rf.data))" />

It's used to get the messages into the main chat window. Here is the TopicContext declaration and main methods from the ChatBean which are generates events for that push:

import org.richfaces.application.push.TopicKey;
import org.richfaces.application.push.TopicsContext;
...
private transient TopicsContext topicsContext;
public String getMessagesSubtopic() {
   return this.getUserName() + SUBTOPIC_SEPARATOR + channelName;
}
private TopicsContext getTopicsContext() {
if (topicsContext == null) {
topicsContext = TopicsContext.lookup();
}
return topicsContext;
}
@Override
protected void onMessage(String channel, String sender, String login, String hostname, String message) {
   try {
       Message messageObject = new Message(message, sender, DateFormat.getInstance().format(
new Date()));
       getTopicsContext().publish(new TopicKey("chat", getMessagesSubtopic()), messageObject);
   } catch (MessageException e) {
       LOGGER.error(e.getMessage(), e);
   }
}
public void send() {
   this.sendMessage(CHANNEL_PREFIX + channelName, message);
   try {
       Message messageObject = new Message(message, this.getName(), 
DateFormat.getInstance().format(new Date()));
       getTopicsContext().publish(new TopicKey("chat", getMessagesSubtopic()), messageObject);
   } catch (MessageException e) {
       LOGGER.error(e.getMessage(), e);
   }
}

onMessage method - just overriden PircBot method and it's invoked when the message comes from the other chat users. And send method is invoked when we are sending a message. This is a standard JSF action of the send button.

As you can see in order to raise an event for a4j:push we just publish it to the TopicContext. publish method accepts two parameters:

  • TopicKey key - adress which consist of topic and subtopic names.
  • Object data - actual data passed to client side event.

Messages subtopic generated by getMessagesSubtopic() method used by a4j:push component on the page and is unique for every user and channel, so only current user will receive the event populated by the object.

The Message object passed as data is pretty simple POJO with three String properties - author, text and timestamp. It's later used on the client in push oncomplete to create formatted string by getMessageString(data) JavaScript method and later add to chat div:

<script>
    function getMessageString(data){
        return data.author + " - " +data.timestamp+ ": " + data.text;
    }
</script>
IMPORTANT: As was mentioned before the other way to publish an event is by just sending it to JMS bus. So you have no need to use our TopicContext in this common case. We've just used this approach for simple example as we have no components other than our simple JSF bean. See Additional Details section for more information about publishing via JMS bus.

Ajax updates on server-side events using a4j:ajax

Now let's review the second approach to perform updates according to events received by a4j:push:

<a4j:push address="#{chatBean.listSubtopic}@chat" onerror="alert(event.rf.data)">
    <a4j:ajax event="dataavailable" render="users" execute="@none" />
</a4j:push>

It's used to update the rich:list which shows the current channel users. Here is the main methods from the ChatBean which are generates events for that push:

public String getListSubtopic() {
   return this.getUserName() + SUBTOPIC_SEPARATOR + channelName + "List";
}
@Override
protected void onUserList(String channel, User[] users) {
   try {
       getTopicsContext().publish(new TopicKey("chat", getListSubtopic()), null);
   } catch (MessageException e) {
       LOGGER.error(e.getMessage(), e);
   }
}
@Override
protected void onJoin(String channel, String sender, String login, String hostname) {
   try {
       getTopicsContext().publish(new TopicKey("chat", getListSubtopic()), null);
       Message messageObject = new Message("joined channel", sender, 
           DateFormat.getInstance().format(new Date()));
       getTopicsContext().publish(new TopicKey("chat", getMessagesSubtopic()), messageObject);
   } catch (MessageException e) {
       LOGGER.error(e.getMessage(), e);
   }
}

We are using the same publishing through TopicContext at server side just defining different subtopic for that a4j:push. And passing null as data because we do not planning to process anything at client side. That's where:

<a4j:ajax event="dataavailable" render="users" execute="@none" />

come in play. When push receives the event an ajax behavior sends a request which just perform rich:list render with new values. Pretty simple isn't it?

Additional Details

There I want to pay your attention to some details not covered within the article.

Single Connection

As you can see in this example we used two a4j:push component on a single page in order to demonstrate two different ways to process push events. It is important to know that this does not mean wo connections are getting opened. All the instances of the push component uses single connection and only the subscribed one gets the event for processing according to it's adress after some event is received. You can verify that by using Firebug for FireFox for example.

Publishing via JMS bus

JMS messages types supported by push are:

  • ObjectMessage
  • TextMessage

Corresponding data from getObject or getText passed to DataSerializer and getting serialized to the client data(to JavaScript using default serializer).

To be Continued...

And finally I want to announce topics which planned to be covered in next Push related articles.

Integration with CDI events

Being a first class citizen in JEE6 ecosystem CDI getting paid much attention during RichFaces development for sure. And support of CDI event system by a4j:push are also topic for upcoming separate blog entry!

And more...

There are a lot of possibilities with this component, too many to describe using just a single article. So follow our blogs or RichFaces twitter for any future examples and documentation updates related to this great component!


[Get updates of my blogs in twitter]

[My jroller.com blog]

43 comments:
 
24. Mar 2011, 08:31 CET | Link

This is incredible feature and I love it. Richfaces team proved again that RF is top choice JSF component for enterprises. Thanks RF team.

ReplyQuote
 
24. Mar 2011, 11:36 CET | Link
Ilya

Thanks! Let us know about any info or feature missed or not completelly understandable(hope will not find at least during basic examination :) ).. We really need feedback on such big features to make sure them are designed/documented well for the community.

 
26. Mar 2011, 14:45 CET | Link
Bob
This may be a stupid question, but how does the session instance of ChatBean get registered as a jms listener?

Also, does the ContextTopic push data to all clients of the application, or is it somehow tied to a particular session? If its tied to a session, where does that Happen? If not, won't all client in a Subchannel get n messages, where n is the number of Cliennts?


 
29. Mar 2011, 20:35 CET | Link
Bob,

ChatBean is not registered as JMS listener, push component provides JMS listener instead.

Each connected client (i.e. browser window) gets internal push session, so when message is published, it's being broadcast to all active sessions connected to that topic. All sub-channels are connected to the JMS topic, sub-channel name is used in criteria that filters messages.
30. Mar 2011, 16:14 CET | Link
Adriaaaaan

Hi I tried to use this example with glassfish but I just get Class not found exception when trying to use the FilterServlet. Seems to require CometProcessor?

31. Mar 2011, 15:13 CET | Link

Speaking kindly I do not tested it under glassfish. please create forum thread describing current environment and including stacktraces.

08. Apr 2011, 05:51 CET | Link

You need to add the atmosphere-runtime dependencies. If you don't use maven, download this jars:

atmosphere-runtime-0.7.1.jar atmosphere-compat-jbossweb-0.7.1.jar atmosphere-compat-tomcat-0.7.1.jar atmosphere-compat-weblogic-0.7.1.jar atmosphere-ping-0.7.1.jar

you can find all of this from here http://oss.sonatype.org/content/repositories/releases/org/atmosphere/

PS: This only solves the dependencies problem... but I'm new to JMS and I don't know how to configure the JMS in the glassfish admin-console, it's really diferent from the jboss6as admin-console, can somebody be kind to post an example on how to configure the JMS part on glassfish 3.1?

09. Apr 2011, 11:18 CET | Link
Pedro Picapiedra

I'm getting this error when the TopicsInitializer gets called. I'm using glassfish 3.1.

WARNING: MQJMSRA_DC2001: Unsupported:setClientID():inACC=false:connectionId=6046697373872048384
SEVERE: java.lang.ExceptionInInitializerError
        at org.richfaces.application.push.impl.jms.PushContextFactoryImpl.getPushContext(PushContextFactoryImpl.java:54)
        at org.richfaces.application.push.TopicsContext.lookup(TopicsContext.java:74)
        at com.dotachile.pushmaven.TopicsInitializer.processEvent(TopicsInitializer.java:38)
        at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106)
        at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2129)
        at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2105)
        at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:300)
        at com.sun.faces.config.ConfigManager.publishPostConfigEvent(ConfigManager.java:603)
        at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:369)
        at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
        at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4690)
        at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:534)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:5305)
        at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
        at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
        at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
        at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
        at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
        at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
        at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
        at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
        at com.sun.grizzly.comet.CometEngine.executeServlet(CometEngine.java:444)
        at com.sun.grizzly.comet.CometEngine.handle(CometEngine.java:308)
        at com.sun.grizzly.comet.CometAsyncFilter.doFilter(CometAsyncFilter.java:87)
        at com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:171)
        at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:143)
        at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:94)
        at com.sun.grizzly.http.TaskBase.run(TaskBase.java:193)
        at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:175)
        at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:145)
        at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:204)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.FacesException: MQJMSRA_DC2001: Unsupported:setClientID():inACC=false:connectionId=6046697373872048384
        at org.richfaces.application.push.impl.jms.PushContextImpl.init(PushContextImpl.java:123)
        at org.richfaces.application.push.impl.jms.PushContextFactoryImpl.createInstance(PushContextFactoryImpl.java:48)
        at org.richfaces.application.push.impl.jms.PushContextFactoryImpl.access$000(PushContextFactoryImpl.java:33)
        at org.richfaces.application.push.impl.jms.PushContextFactoryImpl$PushContextHolder.<clinit>(PushContextFactoryImpl.java:37)
        ... 58 more
Caused by: javax.jms.JMSException: MQJMSRA_DC2001: Unsupported:setClientID():inACC=false:connectionId=6046697373872048384
        at com.sun.messaging.jms.ra.DirectConnection._unsupported(DirectConnection.java:982)
        at com.sun.messaging.jms.ra.DirectConnection.setClientID(DirectConnection.java:487)
        at org.richfaces.application.push.impl.jms.MessagingContext.start(MessagingContext.java:113)
        at org.richfaces.application.push.impl.jms.PushContextImpl.init(PushContextImpl.java:117)
        ... 61 more
10. Apr 2011, 02:32 CET | Link
Paul M.

maybe this has something to do with this problem in glassfish.

http://old.nabble.com/jms-durable-subscriber-fail-%28Unsupported%3AsetClientID%28%29%3AinACC%3Dfalse%29-td25364251.html

09. May 2011, 00:21 CET | Link
Nick Belaevski

Related to GlassFish, please take a look here: JIRA

19. May 2011, 15:55 CET | Link
birol karatay | birolkaratay(AT)gmail.com

I've tried to do myself this sample but I've got some errors while running.

I'm using Jboss 6.0 Final AS. I've downloaded from SVN and made a web application. I added all libraries to lib folder. When I started to JBoss I got this code:

16:34:35,173 ERROR /irc-client Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossMojarra20ConfigureListener: java.lang.NoClassDefFoundError: org/atmosphere/cpr/AtmosphereHandler at org.richfaces.application.push.impl.jms.PushContextFactoryImpl.createInstance(PushContextFactoryImpl.java:47) :4.0.0.Final at org.richfaces.application.push.impl.jms.PushContextFactoryImpl.access$000(PushContextFactoryImpl.java:33) :4.0.0.Final at org.richfaces.application.push.impl.jms.PushContextFactoryImpl$PushContextHolder.(PushContextFactoryImpl.java:37):4.0.0.Final at org.richfaces.application.push.impl.jms.PushContextFactoryImpl.getPushContext(PushContextFactoryImpl.java:54) :4.0.0.Final at org.richfaces.application.push.TopicsContext.lookup(TopicsContext.java:74) :4.0.0.Final at org.ircclient.listeners.TopicsInitializer.processEvent(TopicsInitializer.java:52) at javax.faces.event.SystemEvent.processListener(SystemEvent.java:102):2.0.3-FCS at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2040) :2.0.3-FCS at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2016) at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:298):2.0.3-FCS at com.sun.faces.config.ConfigManager.publishPostConfigEvent(ConfigManager.java:598) :2.0.3-FCS at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:341) :2.0.3-FCS at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:220) :2.0.3-FCS at org.jboss.web.jsf.integration.config.JBossMojarraConfigureListener.contextInitialized(JBossMojarraConfigureListener.java:58) :1.0.3

Please Help me...

 
06. Jun 2011, 13:44 CET | Link

Nice article! I only had troubles with connecting to the IRC server, but now it works with another! :)

Thanks!

17. Jun 2011, 17:09 CET | Link

Anybody can provide an example to set up server push with JBoss 4.2.1? The RichFaces 4 showcase examples and core-demo are working with JBoss 4.2.1.

Need it urgently. I made prototyping with Richfaces 3.3.3. Now I am at the point to decide using RF3 or RF4 in the real development.

Also where to find url for tag library of RF4 like RF 3: http://docs.jboss.org/richfaces/latest-3-3-X/en/tlddoc/

20. Jun 2011, 16:17 CET | Link
Don Samson

Hi ,

Me too in the same boat..

With Jboss 6 i am able to run ircclient sample. I was trying to make it working with Jboss 4.2.1. I see that my messages are getting published. however i don't see the push getting update. I just wrote one more test subscriber for the same topic. I get the messages in my client but push is not getting it. I don't get my error too. Here is my JBoss 4.2.1 Mbean set up. My Topic declaration.

 

<mbean code="org.jboss.mq.server.jmx.Topic"
           name="jboss.mq.destination:service=Topic,name=chat">
     <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
           <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
           <attribute name="SecurityConf">
                      <security>
                              <role name="guest" read="true" write="true" create="true"/>
                      </security>
                    </attribute>
          <attribute name="useDLQ">jboss.messaging.destination:service=Queue,name=DLQ</attribute>
   </mbean>
Do I need to do something about DLQ? I made this and Durable subsription

10. Jul 2011, 14:44 CET | Link

Hi, In fisrt i'll find 'cool' chat application. The sample seems easy when you use 'static' topics.

For my application i don't see how to do it, because i've a private chat ( each user have a single popup divided in twoo parts :

  1. a list with correspondants
  2. the conversation historic of selected correspondant in the list ( 1 )

Actually in richfaces 3.3.3 i use a a4j push, which interrogate a map of conversation in a bean session of each user logged and connected to the chat.

With this mechanism of JMS i don t see how i can do it?

  1. So is it possible to create/delete dynamically a TOPIC in JMS.?
  2. Or does it exist another way?
  3. I think in particular to 'glue' the push to the chat bean in each session.

If you ave an idea of the best usage i can do the new push in RF 4, I m very interresting.

Thanks

 
16. Jul 2011, 17:37 CET | Link
Edward
Is it possible to use the push feature without JMS?
I agree that JMS integration is great in certain cases - such as when you need to integrate with other systems, but I have a stand-alone web application that doesn't need JMS for any reason. The application generates events, and I want to push them to the user. I currently do this with RichFaces 3.x and it works perfectly.
I'd like to upgrade to v4, but I really don't want to install & configure a JMS server - it complicates the architecture and introduces additional dependencies for no good reason (in my case). So... can I still simply push directly to this component without JMS?

Thanks in advance.
 
26. Jul 2011, 10:22 CET | Link
as7question

Hi, I m going tu use jboss AS 7( no jms). How can we use push with other that jms? Thanks

 
17. Nov 2011, 17:55 CET | Link
Pier
At the moment the only place to review that configuration is with our developer demo which configured for tomcat using external HornetQ dependencies and configuration class for its initialization.

Where??? Could you kindly point me to the download page of the developer demo or to an example in order to be able to use push on tomcat?

Thanks a lot

 
20. Nov 2011, 18:40 CET | Link
Flavio

I agree with Pier, it would be very fine knowing where is that docs. Thanks a lot

 
21. Nov 2011, 20:45 CET | Link
Flavio

Hi Pier, look at these links : http://anonsvn.jboss.org/repos/richfaces/branches/4.0.X/examples/irc-client/ http://anonsvn.jboss.org/repos/richfaces/branches/4.0.X/examples/push-demo/ If you could get a working tomcat environment with a4j:push (richfaces 4), please submit your tomcat and hornetq config files.

02. Dec 2011, 08:15 CET | Link
Mario

Is it possible to configure jms push mechanism for the following scenario:

- My RichFaces (4.0.0.Final) application runs on tomcat (6.0.33) - My ActiveMQ runs as an osgi bundle within servicemix configured with just on jms topic

Several osgi bundles publish messages for all RichFaces application users. So I'm only interested in push notifications.

Here my back end bean regarding ActiveMQ connection initialization:

// Create a ConnectionFactory
            ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");

            // Create a Connection
            jmsConn = connectionFactory.createTopicConnection();
            jmsConn.start();

            // Create a Session
            jmsSession = jmsConn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

            //Create a Topic
            jmsTopic = jmsSession.createTopic(JMS_TOPIC_NAME);

            //Create a Subscriber
            jmsSubscriber = jmsSession.createSubscriber(jmsTopic);
            jmsSubscriber.setMessageListener(new MessageListener() {

                @Override
                public void onMessage(Message message) {
                    
                    try {
                        getTopicsContext().publish(new TopicKey(JMS_TOPIC_NAME), message);
                    } catch (MessageException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (JMSException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            });
How should the web.xml file looks like?

Thanks a lot!

 
23. May 2013, 05:04 CET | Link
Vivek

Is there any special configuration that needs to be done on Apache Webserver fronting RichFaces for the same? I got the sample running on Glassfish. Later, I configured Apache fronting Glassfish. I can reach application pages via apache. But, the message consumer page is not displaying the messages.

07. Jun 2014, 16:48 CET | Link

Luckily for you there are other ways for you to get free stuff online. Using coupons for free stuff is one of the great ways to save money on products that you find on the Internet. Often times, organizations use these coupons to offer their clients free merchandise for trial use.things for free

09. Jun 2014, 10:24 CET | Link

Actual product packaging and materials may contain more and different information than what is shown on our website. We recommend that you do not rely solely on the information presented and that you always read labels, warnings, and directions before using or consuming a product. Please see our full disclaimer below. check out this site

10. Jun 2014, 08:34 CET | Link

Actual product packaging and materials may contain more and different information than what is shown on our website. We recommend that you do not rely solely on the information presented and that you always read labels, warnings, and directions before using or consuming a product. Please see our full disclaimer below. forskolin

11. Jun 2014, 19:01 CET | Link

Además, cuando se trata de lo que necesita, en el verdadero sentido de la palabra, un sistema decente de pesos, un estante de la energía y un banco realmente es probablemente todo lo que necesita cargar el tren la mayoría de los principales grupos de músculos en su cuerpo. Supongo que sus dorsales podrían beneficiarse de una barra de dominadas.home gym

23. Jun 2014, 10:59 CET | Link

This site is a leading resource for information about the Igor Ledochowski Power Of Conversational Hypnosis PDF book and hypnotic training system that teaches you effective techniques for influencing and persuading people to give you exactly what you want during everyday conversations.https://www.rebelmouse.com/powerofconversationalhypnosis/

 
24. Jun 2014, 22:39 CET | Link

The reason I say this is because it teaches you the wrong habits from the beginning, and when you decide to switch from the forex demo accounts to a live account it is usually a fiasco, and you are not ready to trade live at all. Usually there is no stop loss used, and usually the forex practice accounts contains about $50 000 an amount of capital that most traders will not have in their real trading accounts. They will leave trades open that will run against them for huge amounts not taking the loss, and stay in the trade to close it later for a small profit

27. Jun 2014, 12:13 CET | Link

Folkersystem Vert Shock: Adam Folker And Justin 'Jus Fly' Darlington Reveal An Insane Method To Pump Up Your Vertical By 9-15 Inches And Throw Down Dunks On Helpless Defenders Like A Total Badass... https://www.rebelmouse.com/folkersystemvertshockreviews/

02. Jul 2014, 09:02 CET | Link

Or the increasing waist line which gives you nightmares daily? Today’s lifestyle is full of junk food and oily components staring at us at each meal, and hence maintaining the shape of the body and staying fit are both big challenges. To get rid of the fat and also to keep control over your appetite so that we do not end up adding more oil is the thought of the day for many of us. And anyone who can help us is that turns out to be our best friend.Mitchell Hall

02. Jul 2014, 10:20 CET | Link

In the super busy world where our days are busy in the office and nights are sleepless with hard partying, health and weight management are the two things that we are always worried for! Anyone who can give you the secret to the world of less fat be in shape will surely be your best friend.Katie Lawson

02. Jul 2014, 10:50 CET | Link

Scientific research has proven that Hydroxycitric acid or better known as HCA is present in plenty in the skin of the Garcinia CAMBOGIA fruit and hence the fruit rind provides us with the fat burning and fat blocking action. It is also known to be one of the best appetite controllers present in our diet.Jeffery Bridges

02. Jul 2014, 11:27 CET | Link

PURE GARCINIA CAMBOGIA EXTRACT originally a prescription of the South East Asian civilisations has been used since ages as a great nutrient supplement and was always popular till now in this South East Asian region. But once it was discovered that PURE GARCINIA CAMBOGIA EXTRACT made from the rinds of the skin of the fruit of the Garcinia Cambogia plant, has weight reduction and fat burning properties- there was surely no looking back.Wade Harrison

02. Jul 2014, 15:31 CET | Link

Scientific research has tested that Hydroxycitric acid or better known as HCA is present in the skin of the PURE GARCINIA CAMBOGIA fruit and hence the fruit skin rind provides us with the fat burning and fat blocking chemical. It is also known to be a great appetite controller.Faith Norris

02. Jul 2014, 16:03 CET | Link

They offer valuable insights about the product such as “Combining Garcinia Cambodia with a colon cleanse product can double your weight loss.” They say that by starting the diet with a completely clean system and getting rid of junk and fatty deposits in the body, your weight loss program can be “kick started,” showing the results earlier. The company’s manager also gives advice when and if needed through a question box at this site.Diana Higgins

06. Jul 2014, 11:33 CET | Link

The Michael Fiore Text Your Ex Back 2.0 PDF and multimedia texting system is here! Read reviews, get download and purchase links, and learn about Michael Fiore text examples and techniques to get your ex back.best way to get my ex back

06. Jul 2014, 14:24 CET | Link

This site is a leading resource for information about the James Ward Cruise Control Diet PDF book and complete weight loss system that teaches you a practical way to drop 10% of your body weight in 30 days or less and ultimately achieve permanent fat loss and better health.take a look here

 
12. Jul 2014, 07:55 CET | Link
been looking

This topic is something that I have been looking into for a while now and your insight is exceptional. Thanks for sharing this information. venus factor system

12. Jul 2014, 21:24 CET | Link

I found this is an informative and interesting post so i think so it is very useful and knowledgeable. I would like to thank you for the efforts you have made in writing this article.www

 
14. Jul 2014, 02:47 CET | Link

Or the increasing waist line which gives you nightmares daily? Today’s lifestyle is full of junk food and oily components staring at us at each meal, and hence maintaining the shape of the body and staying fit are both big challenges. To get rid of the fat and also to keep control

 
15. Jul 2014, 14:28 CET | Link
southern

Hawaii is expensive when you come from the southern United States). Because this was a long time ago, the Scripting Wife was not as Internet savvy as she is today. the venus factor

17. Jul 2014, 18:52 CET | Link

Below you will find the important facts and figures I feel every consumer should know surrounding Mike Walden's Acne No More book and complete holistic guide for getting rid of acne and achieving clear skin at home. https://www.rebelmouse.com/mikewaldenacnenomorereview/

19. Jul 2014, 09:15 CET | Link

After conducting my own investigative Girlfriend Activation System review, every guy who has ever been confused, nervous, or frustrated around women he likes will benefit from GFAS, but it's my opinion that the program is best suited for guys who are looking for a long-term relationship with just one special girl.christian h. girlfriend activation system review

Post Comment