From jira-events at lists.jboss.org Wed Mar 21 13:50:47 2012 Content-Type: multipart/mixed; boundary="===============9180808388831527132==" MIME-Version: 1.0 From: Stian Thorgersen (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] (RF-12072) Lost event in push Date: Wed, 21 Mar 2012 13:50:47 -0400 Message-ID: <1532234996.23469.1332352247479.JavaMail.tomcat@jira02.app.mwc.hst.phx2.redhat.com> In-Reply-To: 1823827590.22721.1332335688298.JavaMail.tomcat@jira02.app.mwc.hst.phx2.redhat.com --===============9180808388831527132== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ https://issues.jboss.org/browse/RF-12072?page=3Dcom.atlassian.jira.p= lugin.system.issuetabpanels:all-tabpanel ] Stian Thorgersen updated RF-12072: ---------------------------------- Description: = Event can be lost if produced while a response is being prepared. I've atta= ched an example where a push event is used to refresh a count whenever an e= vent 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 return= ing 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} {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 =3D new AtomicInteger(); public int getCount() { int c =3D count.get(); new Thread() { public void run() { try { Thread.sleep(5000); count.incrementAndGet(); TopicKey topicKey =3D new TopicKey("chat"); TopicsContext topicsContext =3D TopicsContext.lookup(); topicsContext.publish(topicKey, ""); } catch (Exception e) { e.printStackTrace(); } }; }.start(); = try { Thread.sleep(10000); } catch (InterruptedException e) { } return c; } } {code} was: Event can be lost if produced while a response is being prepared. I've atta= ched an example where a push event is used to refresh a count whenever an e= vent 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 return= ing the count is removed it all works fine, and the page is refreshed every= 5 seconds, but with the sleep in place it the event is lost. View: {code} {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 =3D new AtomicInteger(); public int getCount() { int c =3D count.get(); new Thread() { public void run() { try { Thread.sleep(5000); count.incrementAndGet(); TopicKey topicKey =3D new TopicKey("chat"); TopicsContext topicsContext =3D TopicsContext.lookup(); topicsContext.publish(topicKey, ""); } catch (Exception e) { e.printStackTrace(); } }; }.start(); = try { Thread.sleep(10000); } catch (InterruptedException e) { } return c; } } {code} = > 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) = > Reporter: Stian Thorgersen > > Event can be lost if produced while a response is being prepared. I've at= tached 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 produce= d while the response is being prepared. Note, if the sleep just before retu= rning the count is removed it all works fine, and the page is refreshed eve= ry 5 seconds, but with the sleep in place the event is lost. > View: > {code} > > > xmlns:f=3D"http://java.sun.com/jsf/core" > xmlns:h=3D"http://java.sun.com/jsf/html" > xmlns:a4j=3D"http://richfaces.org/a4j" > xmlns:rich=3D"http://richfaces.org/rich"> > > > > > > > > > > > > > {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 =3D new AtomicInteger(); > public int getCount() > { > int c =3D count.get(); > new Thread() > { > public void run() > { > try > { > Thread.sleep(5000); > count.incrementAndGet(); > TopicKey topicKey =3D new TopicKey("chat"); > TopicsContext topicsContext =3D 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 administrato= rs: https://issues.jboss.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira =20 --===============9180808388831527132==--