Salut,
On 10-09-17 10:40 AM, Paul Sandoz wrote:
> Hi,
>
> Jean-Francois can you recall what the developer needs to do with
> Atmosphere to support simple non-blocking async responses? IIRC you
> blogged about it?
>
> E.g. so a developer can do something like this:
>
> to return a simple async response e.g.:
>
> public void get(AsyncResponse ar) {
> // create new thread wait on IO then set Response on ar
> // return immediately
> }
Do you means:
> @Path("/")
> public class SimpleResource
> {
>
> @GET
> @Path("basic")
> @Produces("text/plain")
> @Suspend(period=30)
> public void getBasic(final Response response,
> final @PathParam("topic") JerseySimpleBroadcaster broadcaster) throws Exception
> {
> Thread t = new Thread()
> {
> @Override
> public void run()
> {
> try
> {
> Response jaxrs = Response.ok("basic").type(MediaType.TEXT_PLAIN).build();
> response.setResponse(jaxrs);
> broadcaster.broadcast(response);
> }
> catch (Exception e)
> {
> ....
> }
> }
> };
> t.start();
> }
> }
A+
-- Jeanfrancois
>
> Paul.
>
> On Sep 15, 2010, at 9:52 AM, jfarcand wrote:
>
>> Salut,
>>
>> On 10-09-15 12:12 PM, Chris Toomey wrote:
>>> We're looking to use both Jersey/JAX-RS and Jetty async continuations
>>> (later the equivalent async mechanism in the Servlet 3.0 API) for
>>> implementing a web service, and looking at the JAX-RS spec.
>>> (https://jsr311.dev.java.net/nonav/releases/1.1/spec/spec.html) it looks
>>> like the API model is incompatible w/ the async continuations model.
>>> Specifically, it stipulates that resource class methods must return a
>>> return value and that if it's void, an immediate 204 response is sent.
>>>
>>> Can anyone confirm this or explain how a Jersey/JAX-RS resource method
>>> would suspend itself w/o causing the response to the client to be
>>> committed?
>>>
>>
>> Have you looked at Atmosphere (which support exactly what you want)?
>>
>> http://atmosphere.dev.java.net
>>
>> Atmosphere has a module called Atmosphere Jersey which is exactly what
>> you are looking for. It works in all WebServer and support Servley 3
>> as well.
>>
>> As for your question, I don't think you can use Jetty Continuation
>> directly with Jersey. You need a framework (like Atmosphere) to
>> intercept the request under the hood and prevent Jersey from
>> committing the response.
>>
>> You can take a look at Atmosphere's code if you want:
>>
>> http://github.com/Atmosphere/atmosphere
>>
>> Look for AtmosphereFilter (Jersey's Filter) and JettyCometSupport.
>>
>> A+
>>
>> -- Jeanfrancois
>>
>>
>>
>>> thx,
>>> Chris
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>