[jboss-as7-dev] Add Notification support to the domain management API

Jeff Mesnil jmesnil at redhat.com
Wed Feb 27 12:14:34 EST 2013


Le 26 févr. 2013 à 18:37, David M. Lloyd <david.lloyd at redhat.com> a écrit :

> On 02/15/2013 11:00 AM, Jeff Mesnil wrote:
>> For the Web console (running in a Web browser), using the Web Sockets
>> protocol seems a natural fit to handle notifications but that support
>> web sockets protocol from AS7 management service (not sure if it's
>> already in the pipeline).
> 
> I don't know, it seems like overkill.  I think 
> http://html5doctor.com/server-sent-events/ is probably a better option 
> than web sockets or polling as it is supported in the browser with a 
> simple API and doesn't require a lot of complex server-side support.

HTML5 server-sent events looks interesting and I like their simplicity.
The only thing I don't like is that the client can only send parameters using the URL to connect to the event source. That makes for looong URL if you want to listen to multiple resources.
For example, to listen to notifications on hornetq-server, jms-queue & jms-topic, the client must connect to:

/notification/sse?address=/subsystem%3Dmessaging/hornetq-server%3D*&address=/subsystem%3Dmessaging/hornetq-server%3D*/jms-queue%3D*&address=/subsystem%3Dmessaging/hornetq-server%3D*/jms-topic%3D*

Using WebSocket makes the communication between the client and the server much straightforward (and similar to the resources of the HTTP API).

I cooked up a quick & dirty prototype with our current HTTP server[1] and it works fine (but not efficiently).
I checked it with the latest chrome/safari/firefox and all worked as expected.
However IE does not support them at the moment[2] and we'd have to provide a polyfill for it.

Web Socket support is more widespread[3] and it seems there is more activity around WebSocket than server-sent events (when they are comparable…)
Undertow provides a WebSocket support that we can leverage and hides the complexity (from the management pov).

Server-sent events:
* pros
  * simple
  * work with our current management HTTP server
* cons
  * no IE support means to provide a polyfill alternative (identical to long polling)
  * long URL (I worry we could hit a limit if the browser want a single event source to list to many resources)

WebSockets:
* pros
  * widespread support
  * richer communication from the client to the server
* cons
  * not working today (depends on undertow that should be integrated soon)

I don't have a sting opinion on this but I'd favor the WebSocket technology.
Our web browser experts should have a say on what they'd prefer use.

jeff

[1] https://github.com/jmesnil/jboss-as/blob/AS7-370_notification_with_server-sent_events/domain-http/interface/src/main/java/org/jboss/as/domain/http/server/NotificationApiHandler.java#L219
[2] http://caniuse.com/#feat=eventsource
[3] http://caniuse.com/#feat=websockets

-- 
Jeff Mesnil
JBoss, a division of Red Hat
http://jmesnil.net/




More information about the jboss-as7-dev mailing list