users@jax-rs-spec.java.net

[jax-rs-spec users] Re: Proposal to drop non-blocking I/O from JAX-RS 2.1

From: Santiago Pericas-Geertsen <santiago.pericasgeertsen_at_oracle.com>
Date: Tue, 4 Apr 2017 13:36:23 -0400

Hi Sergey,

>> We certainly discussed the original proposal while investigating alternatives. However, there are some problems with that approach as well:
>>
>> (1) It does not integrate as nicely with there rest of the JAX-RS pipeline (filters, interceptors, etc.) mainly because it is too stream oriented
> Why not, one the server read side NIO is initiated after the resource method is invoked.

 You mean in the MBR or by application code in the resource method?

> On the write side it is initiated once MBW is reached (I linked you to the CXF code which does it).
> In both cases readers/writers, filters are checked

 My main point was that supporting NIO in resource methods is insufficient. That is not the main use case for JAX-RS. Support for POJOs, and perhaps more importantly, collection of POJOs (as those tend to suffer more from blocking IO) is important. If you recall in the proposal we were experimenting, we found the need for a new type of readers/writers.

>>
>> (2) Supporting this approach and something similar to Flows may result in a “bloated” API with two disjoint solutions for related problems
> I don't think there's any similarity here between m01 and what was proposed later. m01 server NIO API is an entry level, basic NIO API

 That is sort of the point. If we do basic now and advanced later, and the latter is unrelated to the former, we get an ugly duckling.

>>
>> Thus, we concluded that more experimentation is required in order to achieve a single, unified API.
>>
>> It goes without saying that JAX-RS is a standard API, and once something is added, it is needs to be supported basically forever. Thus, we shouldn’t add anything unless we have real evidence that “it works”.
>
> It does work in CXF, I linked you to our code earlier. It works because Servlet 3.1 NIO API works and I said all the m01 API offers is a simple wrapper aroung Servlet 3.1 API. It is straightforward and indeed it works alongside the filters/interceptors

 How much feedback have you received on it? I think it is perfectly fine for implementations to do this, in fact, we need it. But this discussion is about API maturity and standardization, and our recent investigation has sort of question this.

— Santiago

>
>> — Santiago
>>
>>>> On 04/04/17 14:49, Sergey Beryozkin wrote:
>>>>> Hi Pavel
>>>>>
>>>>> It's disappointing even though I appreciate the effort done so far. Probably the most important feature we could've done and now we will face +N (or more) years of waiting for JAX-RS be NIO ready, and by the time it will happen everyone will already be using Spring RS anyway who are charging ahead as we speak with top-class Reactive support...
>>>>> I don't know, we will have though SSE which not all browser implement, I'd rather have only NIO instead of SSE.
>>>>> The 'Flow' duplication argument is not convincing because I believe you had a plan after all to get rid of it when we get to Java 9.
>>>>> The mid of April constraints just highlights that the process once again defeats us completing the work which was planned
>>>>>
>>>>> Thanks, Sergey
>>>>>
>>>>> On 03/04/17 17:40, Pavel Bucek wrote:
>>>>>> Dear EG members,
>>>>>>
>>>>>> As you all know we have been hard at work trying to come up with an NIO proposal based on Flows. In doing so, we have come to the conclusion that this is indeed a really hard problem --lots of small details that need double clicking! After some deliberation, we have come to the conclusion that it is better to drop this feature from this dot release. Here is the rationale for doing so:
>>>>>>
>>>>>> - Working backwards from the officially committed Java EE 8 release date - July 2017 - we need to start Public Review in the middle of April, which means that at this point we don't have enough time to do a design, implementation prototype and gather appropriate feedback.
>>>>>> - Current proposal is based on a Flow-like API, which would force us to duplicate the JDK 9 Flow concept in the JAX-RS 2.1 API.
>>>>>> - We don't want to introduce "just another non-blocking API", which might be deprecated very soon (when Java 9 is released).
>>>>>> - We need some time to work on "smaller issues", which would be most likely not possible if we'll continue working on NIO.
>>>>>>
>>>>>> What does that mean for the current state of the API?
>>>>>>
>>>>>> We will remove Flow.* interfaces and its usage in existing APIs, which means adjustments in SSE part of the spec. Also, we will be making at least some improvement, more related to already introduced Reactive API - support for returning CompletionStage from the resource method. It was in our last version of the high level non-blocking API; CompletionStage is basically a Mono - publisher of a single item. Resource method could then look like:
>>>>>>
>>>>>> @POST
>>>>>> @Path("acceptProduceSource")
>>>>>> public CompletionStage<AnotherPOJO> echoNioEntity(POJO requestEntity) {
>>>>>>
>>>>>> // not blocking the thread, returning CompletionStage and doing the work elsewhere.
>>>>>> return ...;
>>>>>>
>>>>>> }
>>>>>> This improvement will simplify use of the new JAX-RS 2.1 reactive client API in a JAX-RS resource method. Note that this is already tracked as https://java.net/jira/browse/JAX_RS_SPEC-546 <https://java.net/jira/browse/JAX_RS_SPEC-546>.
>>>>>> As always, any comments or suggestions are appreciated.
>>>>>> Thanks and regards,
>>>>>> Pavel & Santiago
>>>>>>
>>>>>
>>>>
>>>
>>
>