jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: [jax-rs-spec users] Re: JAX-RS 2.0 API for asynchronous server-side request processing

From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
Date: Mon, 25 Jul 2011 09:53:10 -0400

On Jul 25, 2011, at 8:31 AM, Bill Burke wrote:

> In Resteasy, we do something much simpler than Atmosphere and the app-developer decide how they want to handle responses. Atmosphere seems a little ambitious to add to the spec as it looks like a full messaging solution, but I'm willing to support the addition as it looks kinda cool.

 We need to decide if want to support "collaborative" applications (like chat) in which messages can be broadcasted to multiple (suspended) connections. On the one hand, these apps are getting ever more popular (with new HTML5 protocols like Server Sent Events and Websockets) and it would be nice to support them; on the other, sending multiple, short messages over the same connection (HTTP streaming) raises some questions in relation to filters, MBR/MBW and the JAX-RS pipeline.

>
> Here's what resteasy looks like.
>
> 1. All async methods must return void
> 2. A callback interface is injected.

 Yes, this is simple and elegant but there's no support for broadcasting. This would be the so-called request scope in the wiki's proposal.

-- Santiago

>
>
> @GET
> public void get(final @Suspend(timeout=5) AsyncResponse async)
> {
>
> Thread t = new Thread() {
> public void run() {
> Response r = Response.ok("hello", "text/plain");
> async.setResponse(r);
> }
> };
> t.start();
> }
>
> interface AsyncResponse {
> void setResponse(Response r);
> }
>
> There's really no other method because the user should be responsible enough to send back a response. I could see a timeout method or suspend method being added.
>
> As for interceptor chains, MBR and filters are invoked for the initial request. Outgoing MBW and filters happen when async.setResponse() is invoked.
>
> On 7/20/11 2:49 PM, Marek Potociar wrote:
>> Hello experts,
>>
>> As announced last week, we have moved the asynchronous server-side processing API in front of some other topics in the
>> schedule. I have wrote up a wiki page[1] discussing the problem domain in which I am also including some motivating
>> examples, initial requirements and open topics to start the expert discussion.
>>
>> Please read through the wiki page[1] and send your thoughts to the EG list. Also, feel free to add new sections,
>> reference links, requirements or open topics to the document, just make sure to mark the additions with your name.
>>
>> Let's shoot for finishing the first round of collecting the initial EG feedback on Friday (July 29) next week.
>>
>> Thank you,
>> Marek
>>
>> [1] http://java.net/projects/jax-rs-spec/pages/AsyncServerProcessingModel
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com