views:

179

answers:

2

Hi - how do I push server alerts to tray apps in java without using xmpp or other heavy protocols?

Do you recommend a way to accomplish this?

I was planning to write an app which uses URLConnection on a server equipped with Comet but I doubt if that would work as the client requires a JS to be invoked and URLConnection is not a browser..

What is the best way to push instead of using a proprietary client-server approach?

A: 

If you have a java capable server and java clients, I would seriously consider using Apache ActiveMQ. A JMS topic works really well for this kind of push things (unless you have ambitions to dethrone twitter).

When other things need to get access to these notifications, it might be good to look at Apache Camel. This allows the notifications to be accepted and routed to different locations, i.e. xmpp, email, http, dropping files in a directory,.... Camel comes with a whole bunch of existing interface to various protocols. It has some simple DSL's to quickly reconfigure routings and add protocols or other filter, transformers, etc...

Both products are extremely simple to embed in an existing application.

Peter Tillemans
+1  A: 

I use Growl on my Mac for local notifications from my apps, but you can also send Growl remote notifications. There's also a Windows version, as well as a Java library available. Here's the example Java code (needs Java 6):

// give your application a name and icon (optionally)
Application serverApp = new Application("Server App");

// create reusable notification types, their names are used in the Growl settings
NotificationType start = new NotificationType("ServerStart");
NotificationType shutdown = new NotificationType("ServerShutdown");
NotificationType[] notificationTypes = new NotificationType[] {start, shutdown};

// connect to Growl on the given host
GrowlConnector growl = new GrowlConnector("localhost");

// now register the application in growl
growl.register(serverApp, notificationTypes);

// finally send the notification
growl.notify(new Notification(serverApp, start, "Server is starting", "Good luck"));
Christoph Metzendorf