WebSockets EAP 6.3, what is that?

One of the new features included on JBoss EAP 6.3 is WebSockets, but what is it?

JSR-356 define a WebSocket as a bi-directional communication mechanism between client (browser) and server, allowing simultaneous messaging. We worked with applications which client, through a request, receive a response from server, but server only send data if the client asks. With the WebSocket API, the server is allowed to send data without a request from the client, establishing a single connection (socket) between the client and the server.

But what utility has?

Consider for a moment an application for a travel agency with a drop-down menu containing available flights between two destinations; know that many travel agents are accessing the same data so that a flight could be filled and should not be chosen. Prior to WebSockets, thank to AJAX, we could have the problem solved, but overloaded with constant requests of kind “something has changed?” then the server responds by sending the new view of flights.
The great advantage of the WebSockets is if a travel agency complete a flight, our application would not have to ask to server if something had changed but the server directly sendschanges and regenerate the view of our menu.

The WebSockets appear in the Java EE 7 how is it possible to use EAP 6.3?

It’s true that JBoss EAP 7 will be Java EE 7 Compliant, while EAP 6.3 is Java EE 6 Compliant, but we can use WebSockets modifying a descriptor file in our application,  WEB-INF/jboss-web.xml enabling WebSocket as well:

<jboss-web version="7.2" 
   xmlns="http://www.jboss.com/xml/ns/javaee" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee schema/jboss-web_7_2.xsd">
    <enable-websockets>true</enable-websockets>
</jboss-web>

This is enough, if you want to try this feature you can use this chat application.

Enjoy it!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.