Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jaxrs-dev] EventSouce reconnect

Jim,

 I think automatic re-connections should only happen if connections are lost, i.e. abruptly interrupted rather than gracefully terminated. 

 If Jersey is not doing that, it is either a bug or a condition in which it is unable to distinguish abrupt vs. graceful termination (I recall there were some issues when Jersey uses HttpUrlConnection, which is its default connector).

— Santiago

On Mar 14, 2018, at 5:44 AM, Jim Ma <ema@xxxxxxxxxx> wrote:

 CXF 3.2.2 stops reconnecting after event sink is gracefully closed as jaxrs spec says, but Jersey 2.26  keeps reconnecting.  

On Wed, Mar 14, 2018 at 4:54 PM, Markus KARG <markus@xxxxxxxxxxxxxxx> wrote:

I think we should look at what the JAX-RS implementations actually do. What is Jersey doing? What is CXF doing? And then look if they all behave the same and specify that as the Default. It might be a good idea to specify an additional policy Annotation in case the implementations behave differently.

 

Von: Jim Ma
Gesendet: Mittwoch, 14. März 2018 05:49
An: jaxrs developer discussions
Betreff: [jaxrs-dev] EventSouce reconnect

 

When the EventSink is closed after send several events with the following resource method , should EventSource reconnect automatically? 

   @GET

   @Path("/closeAfterSent")

   @Produces(MediaType.SERVER_SENT_EVENTS)

   public void eventStream(@Context SseEventSink eventSink, @Context Sse sse) throws Exception {

      System.out.println("entering eventStream()");

      ExecutorService pool = Executors.newCachedThreadPool();

      OutboundSseEvent.Builder builder = sse.newEventBuilder().mediaType(MediaType.APPLICATION_XML_TYPE);

      pool.execute(new Thread()

      {

         public void run()

         {

            try (SseEventSink sink = eventSink) 

            {

               System.out.println("sending 3 events");

               eventSink.send(builder.data("thing1").build());

               eventSink.send(builder.data("thing2").build());

               eventSink.send(builder.data("thing3").build());

               System.out.println("sent 3 events");

            }

         }

      });

   }

 

In EventSource api doc, it says EventSource will reconnect after connection loss or missing events. Should we add some clarification for this situation ?  I know Firefox or Chrome's EventSource will automatically reconnect after event sink is closed.  Should jaxrs' EventSource do the same ?

 

Thanks,

Jim

 


_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev


_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev


Back to the top