I've been evaluating primefacesPush to use it in production environment but we have some issues with chat example:
1) @pathParam are not always working, despite remoteEndpoint uri has them
In this case, pathSegments from remoteEndPoint did the trick.
2) Chat is working perfectly (global and proivate messages) *but* we don't receive eventBus publish message inside @pushEndponint on @onOpen or @onClose events
Code: Select all
@OnOpen
public void onOpen(RemoteEndpoint r, EventBus eventBus) {
logger.info("OnOpen {}", r);
//It never delivers it
eventBus.publish(room + "/*", new Message(String.format("%s has entered the room '%s'", username, room), true));
}
@OnClose
public void onClose(RemoteEndpoint r, EventBus eventBus) {
ChatUsers users= (ChatUsers) ctx.getAttribute("chatUsers");
users.remove(username);
//It never delivers it
eventBus.publish(room + "/*", new Message(String.format("%s has left the room", username), true));
}
The code is an *exact* copy of the web (with disabled = false of course), this is our web.xml
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<!--<url-pattern>/faces/*</url-pattern> -->
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!--
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
-->
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<!--
<init-param>
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
<param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.util.IOUtils.readGetBody</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.AtmosphereFramework.analytics</param-name>
<param-value>false</param-value>
</init-param>
-->
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
300
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>chat.xhtml</welcome-file>
</welcome-file-list>
</web-app