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

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

Stian, I was talking about queuing mechanism, but we have decided to rather 
support {{subscribed}} event.

Thanks for cooperating on this issue.
                
> Push: add onsubscribed event (was: 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

       

_______________________________________________
richfaces-issues mailing list
richfaces-issues@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/richfaces-issues

Reply via email to