I guess I misread the docs. From: http://tomcat.apache.org/tomcat-6.0-doc/aio.html While talking about EventType.READ: "It is not allowed to attempt reading data from the request object outside of the execution of this method."
Would it be correct to say - Use EventType.READ if you're worried about blocking. EventType.BEGIN generally acts in the same way as the Servlet.service method in the way it blocks. Pseudo code for what we're doing now: public void event(CometEvent event) { if (event.getEventType() == BEGIN) { // stash the event as a request attribute // act like nothing is different service(request, response); // sleep is set by the guts of DWR if (!sleep) { event.close(); } } else if (event.getEventType() == ERROR || event.getEventType() == END) { event.close(); } } And then we set sleep == true in the guts of DWR when we want to sleep, having set sleep, we call event.close() when we're done. Everything appears to be working OK now. Many thanks, Joe. On Thu, Jul 17, 2008 at 2:34 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > > what does your HTTP request look like, it would need to have a body for the > READ event to be called. > currently READ doesn't get invoked when you are using a > x-www-form-urlencoded > this was fixed in trunk yesterday, > > http://svn.apache.org/viewvc?rev=677473&view=rev > > also, in your begin event, you can call event.setTimeout if you need a > custom timeout > > Filip > > > > Joe Walker wrote: > >> Thanks for the help Philip. >> >> So I was hoping to use the normal Servlet processing for all requests, and >> then do something special to drop a thread when doing comet. >> My event method looks like this: >> >> public void event(CometEvent event) throws IOException, ServletException { >> if (event.getEventType() == CometEvent.EventType.BEGIN) { >> event.getHttpServletRequest().setAttribute(ATTRIBUTE_EVENT, event); >> } >> else if (event.getEventType() == CometEvent.EventType.ERROR) { >> event.close(); >> } >> else if (event.getEventType() == CometEvent.EventType.END) { >> event.close(); >> } >> else if (event.getEventType() == CometEvent.EventType.READ) { >> // Does this handle blocking reads if we just carry on reading? >> service(event.getHttpServletRequest(), >> event.getHttpServletResponse()); >> } >> } >> >> The effect that I'm seeing is a call to event() with event.getEventType() >> == >> CometEvent.EventType.BEGIN as expected, but I'm expecting some READ >> events, >> but nothing until an ERROR(TIMEOUT) event a bit later. >> >> When Tomcat starts it says: >> Jul 17, 2008 10:35:31 AM org.apache.catalina.core.AprLifecycleListener >> init >> INFO: The Apache Tomcat Native library which allows optimal performance in >> production environments was not found on the java.library.path: >> .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java >> Jul 17, 2008 10:35:35 AM org.apache.coyote.http11.Http11NioProtocol init >> INFO: Initializing Coyote HTTP/1.1 on http-8080 >> Jul 17, 2008 10:35:35 AM org.apache.catalina.startup.Catalina load >> INFO: Initialization processed in 8828 ms >> Jul 17, 2008 10:35:35 AM org.apache.catalina.core.StandardService start >> INFO: Starting service Catalina >> Jul 17, 2008 10:35:35 AM org.apache.catalina.core.StandardEngine start >> INFO: Starting Servlet Engine: Apache Tomcat/6.0.14 >> >> Do I need to fire up a C compiler to get this to work? >> >> Joe. >> >> >> On Thu, Jul 17, 2008 at 4:04 AM, Filip Hanik - Dev Lists < >> [EMAIL PROTECTED]> >> wrote: >> >> >> >>> for your connector element you must have >>> >>> protocol="org.apache.coyote.http11.Http11NioProtocol" >>> or >>> protocol="org.apache.coyote.http11.Http11AprProtocol" (and the APR and >>> tcnative libraries in your PATH/LD_LIBRARY_PATH) >>> >>> Filip >>> Joe Walker wrote: >>> >>> >>> >>>> Hi, >>>> >>>> It looks like servlet spec 3 is waaaay off. So I'm creating a >>>> implementation >>>> of CometProcessor in DWR. >>>> I've created a new CometProcessor like this: >>>> >>>> public class DwrCometProcessor extends DwrServlet implements >>>> CometProcessor >>>> >>>> But the event() method is not called. It just leaps straight to >>>> service(). >>>> Is there anything else I need to be doing (clearly I've changed web.xml >>>> to >>>> point at the new 'servlet' using <servlet-class> >>>> org.directwebremoting.servers.tomcat.DwrCometProcessor</servlet-class>)? >>>> >>>> Joe. >>>> >>>> >>>> ------------------------------------------------------------------------ >>>> >>>> No virus found in this incoming message. >>>> Checked by AVG. Version: 7.5.526 / Virus Database: 270.4.11/1554 - >>>> Release >>>> Date: 7/15/2008 6:03 PM >>>> >>>> >>>> >>>> >>> --------------------------------------------------------------------- >>> To start a new topic, e-mail: users@tomcat.apache.org >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >>> >>> >> >> ------------------------------------------------------------------------ >> >> No virus found in this incoming message. >> Checked by AVG. Version: 7.5.526 / Virus Database: 270.5.0/1556 - Release >> Date: 7/16/2008 4:56 PM >> >> > > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >