tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yann Simon <yann.simon...@gmail.com>
Subject Re: Tomcat 8.0.0-RC5: asynchron IO and back pressure with ReadListener
Date Thu, 30 Jan 2014 16:51:17 GMT
2014-01-30 Rémy Maucherat <remm@apache.org>:
> 2014-01-30 Yann Simon <yann.simon.fr@gmail.com>:
>
>> Hi,
>>
>> I wrote a sample app to demonstrate the problem:
>> https://github.com/yanns/servlet31_async
>>
>> You can generate an exploded war with maven: mvn war:exploded
>> I deployed the application in tomcat 8.0.0-RC10.
>>
>> The 2 upload form does work.
>> The 1st upload form uses a new thread in , and that does not work.
>>
>> https://github.com/yanns/servlet31_async/blob/master/src/main/java/com/yann/ReadListenerImpl.java#L22
>>
>> The "onDataAvailable" is called only one time.
>>
>> With jetty, it does work (mvn jetty:run)
>>
>> I hope this can help.
>>
>
> You must read data until the ready flag flips, and you must do it in the
> onDataAvailable invocation (= synchronously). Asynchronous reads is not the
> threading and sync model that was chosen by the specification, so you
> should simply not do that. I doubt it will reliably work in any container
> since it is almost certain you can run in thread safety issues.
>
> Rémy

Thx for the explanation.
What is the part of the specification that is saying that
onDataAvailbale must be consumed synchronously?
Is it the last sentence "The Servlet container must access methods in
ReadListener in a thread safe manner." from:

"The ReadListener provides the following callback methods for non blocking IO -
■ ReadListener
■ onDataAvailable() . The onDataAvailable method is invoked on the
ReadListener when data is available to read from the incoming request
stream. The container will invoke the method the first time when data is
available to read. The container will subsequently invoke the onDataAvailable
method if and only if isReady method on ServletInputStream , described
below, returns false .
■ onAllDataRead() . The onAllDataRead method is invoked when you have
finished reading all the data for the ServletRequest for which the listener was
registered.
■ onError(Throwable t) . The onError method is invoked if there is any error or
exception that occurs while processing the request.
The Servlet container must access methods in ReadListener in a thread
safe manner."

It means we cannot write real asynchronous reactive applications with
servlet 3.1... disappointing.

Yann

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message