users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: [javaee-spec users] [jsr342-experts] Server-Sent Events in Java EE 8

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Thu, 22 May 2014 23:57:55 +0200

Hi Bill,

See here: http://stackoverflow.com/a/5326159/1016161

TLDR summary:

Advantages of SSE over Websockets:
Transported over simple HTTP instead of a custom protocol
Can be poly-filled with javascript to "backport" SSE to browsers that do not support it yet.
Built in support for re-connection and event-id
Simpler protocol
Advantages of Websockets over SSE:
Real time, two directional communication.
Native suport in more browsers
Ideal use cases of SSE:
Stock ticker streaming
twitter feed updating
Notifications to browser
Cheers,
Marek

On 22 May 2014, at 18:03, Bill Burke <bburke_at_redhat.com> wrote:

> I just hope that you aren't adding support for something that isn't really that well adopted. Are you sure SSE is something people use. I thought Web Sockets was much more prevalent.
>
> On 5/22/2014 10:54 AM, Sergey Beryozkin wrote:
>> Hi Santiago
>>
>> Thanks for the link.
>> So hopefully SSE will be supported in JAX-RS 2.1.
>>
>> What concerns me is this: appears like the decision to use a 'special'
>> media type is already taken, the way the presentation talks about it,
>> and as such the expectations are already there in EE8 team that yeah,
>> this is how it will work.
>>
>> I hope we can take a different approach. @Produce will define a format
>> of the event stream field. The same way it defines the content of HTTP
>> payload which is part of the bigger HTTP response. The acceptance of
>> text/event-stream will be enabled by an SSE enabler annotation. IMHO
>> this will be more JAX-RS friendly. We would even use Response with
>> EventSource. Open question: how to tell the consumer about a field
>> format, guess SSE allows for custom headers/extensions, may be 'comment'
>> can be used as a container.
>>
>> If the 'special' @Produces does stay then we will not help users at all
>> because the format of the field will have no associated metadata, so the
>> field can be a plain text or JSON, the 3rd party client won't know. That
>> said, perhaps in this case, EventOutput would have a way to set
>> Content-Type of the field. This approach still looks less JAX-RS friendly
>>
>> Cheers, Sergey
>>
>>
>> On 22/05/14 14:35, Santiago Pericas-Geertsen wrote:
>>> Dear Experts,
>>>
>>> I'm forwarding a message from Bill Shannon in relation to SSE in EE 8.
>>> Please take a look as this may have an impact on our future work.
>>>
>>> -- Santiago
>>>
>>> Begin forwarded message:
>>>
>>>> *From: *Bill Shannon <bill.shannon_at_oracle.com
>>>> <mailto:bill.shannon_at_oracle.com>>
>>>> *Subject: **[javaee-spec users] [jsr342-experts] Server-Sent Events in
>>>> Java EE 8*
>>>> *Date: *May 21, 2014 at 8:14:46 PM EDT
>>>> *To: *jsr342-experts_at_javaee-spec.java.net
>>>> <mailto:jsr342-experts_at_javaee-spec.java.net>
>>>> *Reply-To: *jsr342-experts_at_javaee-spec.java.net
>>>> <mailto:jsr342-experts_at_javaee-spec.java.net>
>>>>
>>>> One of the items we'd like to add support for in Java EE 8 is
>>>> Server-Sent Events. We've considered several options for how
>>>> to add this support and concluded that JAX-RS seems like the best
>>>> choice. Santiago (JAX-RS spec lead) has written up the options
>>>> and our conclusion here:
>>>> https://java.net/projects/javaee-spec/downloads/download/SSE-in-EE8.pdf
>>>>
>>>> Please let us know if you have any concerns with including SSE
>>>> support in JAX-RS. Otherwise, expect to see this proposed in the
>>>> next JAX-RS JSR, to be submitted this summer.
>>>>
>>>> Thanks.
>>>>
>>>> Bill
>>>
>>
>>
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com