WebSocket is an IETF standard recognized by RFC 6455 and has the following key characteristics which make it great fit for real time applications
- Bi-directional: both server and client an initiate a communication
- Full duplex: once the WebSocket session is established, both server and client can communicate independent of each other
- Less verbose (compared to HTTP)
A deep dive into the protocol is out of scope of this blog. Please refer to the RFC for further details
Java Websocket API
A standard Java equivalent (API) for this technology is defined by JSR 356. It is backed by a specification which makes it possible to have multiple implementations of the same. JSR 356 is also included as a part of the Java Enterprise Edition 7 (Java EE 7) Platform. This includes a pre-packaged (default) implementation of this API as well as integration with other Java EE technologies like EJB, CDI etc.
Tyrus is the reference implementation of the Java Websocket API. It is the default implementation which is packaged with Java EE 7 containers like Weblogic 12.2.1 (and above) and Glassfish (4.x). It provides both server and client side API for building web socket applications.
Tyrus grizzly module
Tyrus has a modular architecture i.e. it has different modules for server, client implementations, a SPI etc. It supports the notion of containers (you can think of them as connectors) for specific runtime support (these build on the modular setup). Grizzly is one of the supported containers which can be used for server or client (or both) modes as per your requirements (the sample application leverages the same)
The sample is a chat application – a canonical use case for WebSockets (this by no means a full-blown chat service). Users can
- Join the chat room (duplicate usernames not allowed)
- Get notified about new users joining
- Send public messages
- Send private messages
- Leave the chat room (other users get notified)
For regular information become a member in the WebLogic Partner Community please visit: http://www.oracle.com/partners/goto/wls-emea ( OPN account required). If you need support with your account please contact the Oracle Partner Business Center.