Headlands Firehose Edition Is Available

Datetime:2016-08-22 22:31:58          Topic: WebSocket           Share

The "Firehose" release (v0.0.4) headlands (a JCache based in-memory grid) delivers CacheEntryEvent s via WebSockets in JSON-format.

Cache change events can be received in real-time from Javaclients:



import javax.websocket.ContainerProvider;
import javax.websocket.DeploymentException;
import javax.websocket.WebSocketContainer;



public class NotificationsReceiver extends Endpoint {

    @Override
    public void onOpen(Session session, EndpointConfig ec) {
        this.session = session;
        this.session.addMessageHandler(new MessageHandler.Whole<String>() {

            @Override
            public void onMessage(String msg) {
            }
        });
    }

}


WebSocketContainer containerProvider = ContainerProvider.getWebSocketContainer();
NotificationsReceiver messagesEndpoint = new NotificationsReceiver();
containerProvider.connectToServer(this.messagesEndpoint, new URI("ws://localhost:8080/headlands/firehose/" + channel));
...or JavaScript:

   this.callback = function(payload){
   
   }

  let socket = new WebSocket(`ws://${this.uri}/headlands/firehose/*`);
   socket.onmessage =  (event) => {
     this.serialize(event.data,this.callback);
   };
   socket.onopen = (event) => {
     console.log("socket connection established",event);
   };

See you at: Building HTML 5 Applications with react.js and Java EE 7 workshops at MUC Airport !

NEW workshop:On demand workshops:,,andare available for streaming




About List