[richfaces-issues] [JBoss JIRA] (RF-12072) Lost event in push

Lukáš Fryč (JIRA) jira-events at lists.jboss.org
Tue Mar 27 03:42:52 EDT 2012


    [ https://issues.jboss.org/browse/RF-12072?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679524#comment-12679524 ] 

Lukáš Fryč commented on RF-12072:
---------------------------------

The proposed solution of queuing requests solves the issue only partially - it significantly decreases probability of losing event, but it still doesn't eliminate it completely.

To ensure completeness, you would need to block until a client is subscribed to a topic before you could continue with rendering of the page.

----

Another suggestion is to create new event {{subscribed}}, allowing you to react on successful subscription with specific action - in this case partial page reload.

----

Still we need to make sure this behavior is documented properly.
                
> Lost event in push
> ------------------
>
>                 Key: RF-12072
>                 URL: https://issues.jboss.org/browse/RF-12072
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: component-push/poll
>            Reporter: Stian Thorgersen
>            Assignee: Lukáš Fryč
>             Fix For: 4.2.1.CR1
>
>
> Event can be lost if produced while a response is being prepared. I've attached an example where a push event is used to refresh a count whenever an event is fired. It's using Thread.sleep to simulate an event being produced while the response is being prepared. Note, if the sleep just before returning the count is removed it all works fine, and the page is refreshed every 5 seconds, but with the sleep in place the event is lost.
> View:
> {code}
> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB"
> 	xmlns:f="http://java.sun.com/jsf/core"
> 	xmlns:h="http://java.sun.com/jsf/html"
> 	xmlns:a4j="http://richfaces.org/a4j"
> 	xmlns:rich="http://richfaces.org/rich">
> <h:head>
> 	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
> </h:head>
> <h:body>
> 	<h:form id="myForm">
> 		<a4j:push address="chat">
> 			<a4j:ajax event="dataavailable" render="count" />
> 		</a4j:push>
> 		<h:outputText value="#{myBean.count}" id="count" />
> 	</h:form>
> </h:body>
> </html>
> {code}
> Bean:
> {code}
> package com.example;
> import java.io.Serializable;
> import java.util.concurrent.atomic.AtomicInteger;
> import javax.enterprise.context.SessionScoped;
> import javax.inject.Named;
> import org.richfaces.application.push.TopicKey;
> import org.richfaces.application.push.TopicsContext;
> @Named
> @SessionScoped
> public class MyBean implements Serializable
> {
>     private AtomicInteger count = new AtomicInteger();
>     public int getCount()
>     {
>         int c = count.get();
>         new Thread()
>         {
>             public void run()
>             {
>                 try
>                 {
>                     Thread.sleep(5000);
>                     count.incrementAndGet();
>                     TopicKey topicKey = new TopicKey("chat");
>                     TopicsContext topicsContext = TopicsContext.lookup();
>                     topicsContext.publish(topicKey, "");
>                 }
>                 catch (Exception e)
>                 {
>                     e.printStackTrace();
>                 }
>             };
>         }.start();
>         
>         try
>         {
>             Thread.sleep(10000);
>         }
>         catch (InterruptedException e)
>         {
>         }
>         return c;
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the richfaces-issues mailing list