Pushing messages to connected clients has always been a need on the web, growing with the apparition of new Rich Internet Applications, like realtime feeds (Gmail, news, market quotes), social feeds (The Twitter, Facebook and consort) and many other providing realtime collaboration, monitoring and control like new Internet of Things applications (FlightRadar24, Arduino #1, #2).
Comet technics (ie. polling, long-polling, streaming) and more recently, the WebSocket protocol, have made possible various webpush applications.
Today, when you want to enable realtime push on your own Java-based webapp, you have several solutions:
- Use an externalized system that will handle that for you (like Pusher), avoiding you the providing of any additional server
- Use a commercial solution (like Kaazing or Diffusion), generally implementing a Message Broker underneath, with both embedded and standalone server
- Use a container-specific api (like Jetty Continuation, Tomcat’s CometProcessor, Grizzly CometHandler or Netty WebSocket), but your application will be strongly coupled with it
- Or use one of the few Open Source frameworks available (like Atmosphere, cometD or JWebSocket)
In this article, I will focus on Atmosphere. After a brief presentation of the framework, I will demonstrate how easy it is to make push-capable applications, whatever the container you use and the nature of your clients.
Before we start, you can take a look at the following video, that demonstrates what I achieved thanks to the Atmosphere framework (more details below, of course):
OpenStreetMap (i.e. OSM) is a community which creates and provides free and open geographic data. The project started because most available maps, such as Google Maps or Bing, have legal or technical restrictions on their use: lot of content are not exposed due to copyrights, belonging to mapping companies (e.g. NAVTEQ or Tele Atlas) or national agencies (e.g. Ordnance Survey or IGN). To see how rich is OpenStreetMap data, you can have a preview via the