Best solution for Java HTTP push (messaging)

crusam picture crusam · Nov 13, 2009 · Viewed 12.5k times · Source

We want to push data from a server to clients but can only use HTTP (port 80). What is the best solution for messaging? One idea is Comet. Are there other ideas or frameworks which offer lets say JMS over HTTP. (Yes, ActiveMQ supports it too, but waggly IMHO. And JXTA supports it too but the configuration is complicated. Something simple is preferred.)

Answer

cletus picture cletus · Nov 13, 2009

The simplest solution for many, many reasons is to use a Comet based approach (like you mention). This means the clients (to whom you want to "push" messages) open long-lived HTTP connections. Those connections stay open until they time out or you send the client a message. As soon as either happens the client opens a new connection.

Directly connecting to clients could be problematic for many reasons: they could be behind firewalls that disallow that, they could be behind proxies and so on.

Unless your clients are real servers (in which case you're really the client), have them contact you and send a response to mimic push.