Tag Archives: websocket

CDI (2.0) Async Events

Glassfish 5 builds for Java EE 8 are rolling along… here is another Docker based example on Github. This time it’s asynchronous events in CDI 2.0 (JSR 365) Steps Just follow the README… just a bunch of docker commands to get … Continue reading

Posted in Docker, Java, Java EE | Tagged , , , , , , , , , | Leave a comment

Accessing HTTP Session in WebSocket endpoint

It’s possible to obtain a reference to the HttpSession within a WebSocket application using a custom implementation of ServerEndpointConfig.Configurator Here is an example application on Github Steps… Override the modifyHandshakeRequest method call the getHttpSession method on the HandshakeRequest object which is passed into the … Continue reading

Posted in Java EE | Tagged , , , , | Leave a comment

kafEEne #1: Websocket & Kafka

Say hello  to kafEEne ! A blog series which will show Kafka and Java EE examples This one is about Kafka + (Java EE) Websocket API. Code is on Github and you can refer to the README on how to get this … Continue reading

Posted in Java EE | Tagged , , , , , , , | 1 Comment

Handling ‘state’ in Java WebSocket applications

By and large, there are two kinds of states in a WebSocket application User/client specific: related to a connected user/Session e.g. user ID, list of subscriptions, last message received etc. Global: state which is relevant across your application and something … Continue reading

Posted in Java, Java EE | Tagged , , | 2 Comments

Trending Meetup groups with Redis and Java EE

This is an application which displays the currently trending Meetup groups based on their (live) RSVPs feed. It’s built using Java EE 7 (uses WebSocket client & server APIs, Singleton EJB timers and CDI events to wire things up) and … Continue reading

Posted in Java, Java EE | Tagged , , , , , , , | Leave a comment

Github: WebSocket applications…

I recently pushed a couple of WebSocket samples to Github. Both are based around the notion of a chat service – a canonical WebSocket example! These were originally meant to serve as additional material to the Java WebSocket API Handbook in order … Continue reading

Posted in Java EE | Tagged , , , | Leave a comment

Quick tip: managing Stateful EJBs in WebSocket endpoints

@Stateful EJBs can be injected in WebSocket endpoints (supported by the WebSocket specification). There is an one-to-one association between the WebSocket client & endpoint (which is by default) as well as the injected Stateful EJB instance, which makes it an good candidate for storing … Continue reading

Posted in Java, Java EE | Tagged , , , , , , | Leave a comment

WebSocket endpoint as Singleton EJB

By default … … a WebSocket implementation creates a new (server) endpoint instance per client. In case you need a single instance, you can implement this using a custom ServerEndpointConfig.Configurator (by overriding the getEndpointInstance method) The catch: you might have to sacrifice some … Continue reading

Posted in Java, Java EE | Tagged , , , , | 3 Comments

New release: Java WebSocket API handbook

Happy to announce the initial release of the Java WebSocket API handbook. This is still a work in progress but moving at a strady pace. You can read this on Gitbook or grab your PDF/ePub/Mobi version from Leanpub   Here is … Continue reading

Posted in Java, Java EE | Tagged , , , , , | Leave a comment

Using Asynchronous timeouts in the Java WebSocket API

Sending messages in an asynchronous manner avoid blocking the sending thread. This is a great where your solution needs to scale in order to support a large number of clients. But there is a limit on how long can we … Continue reading

Posted in Java, Java EE | Tagged , , , , , | Leave a comment