views:

1738

answers:

5

Here are the specs that I'm trying to implement in a nutshell:

1) Some Alerts have to be sent on certain events in the application.

2) These Alerts have Users subscribe to them.

3) And the Users have set their own Notification preferences (e.g. Email and/or SMS).

I have not been able to find an open source solution in Java so far.

Is JMX Notifications an option? The more I read about JMX, the more I feel that it is trying to achieve something different that my problem.

Any help would be useful.

A: 

Do you mean JMS (instead of JMX)? JMS is an messaging API while JMX is a monitoring/administration API. Using JMS as the back end is a good way to implement the back-end messages, it will take care of decoupaging, load balancing, and persistency. But you still have to have a component that receives the messages and send them on to the user.

eishay
A: 

If you mean JMX, there is a JBoss/Nagios bridge called monju that has a generlized JMX hook.

fawce
+6  A: 

JMX can be a mechanism to solve this problem, but it's not the complete solution.

JMX provides facilities and services to your programs to allow clients to access monitoring data as well as allowing clients to make control calls to the application.

As you mentioned, one aspect of JMX is the notification system. What this system provides is infrastructure to make it easy for your program to make alerts and notifications available to clients, and modern JVMs also provide a free JMX server to allow client to connect to your application remotely and subscribe to those events.

But its one thing to make a JMX alert, and it's another thing completely to act on it.

What you would need to do is have some JMX client, somewhere, "subscribe" to the JMX notifications of your programs, and then THAT client can act upon those notification by sending emails, or whatever.

The JMX client can be a remote client talking to your application via TCP, or it can be an internal JMX client within the program, running in a thread, say, and it can act on the notifications.

So, basically, JMX provides the plumbing and infrastructure for what you want to do, but doesn't take it "the last mile" to converting alerts in to emails.

As @fawce mentioned, there are some "generic" JMX clients of various sophistication that can act upon JMX data and may do what you want (I'm not familiar with them, so I can not say first hand), or you can code your own system to monitor the JMX data.

Will Hartung
Nagios is a generic monitoring application that is open source. It has "probes" that live on monitored systems, and it has a dispatcher to convert probe data to alerts (email, sms, IM, etc). It also logs all the alerts. Monju is a generic JMX-Probe for Nagios.
fawce
A: 

I would suggest using JMX notifications and SNMP which should support your scenario, 2) and 3) being covered by the SNMP software.

You could also code it in Java yourself as long as you have access to a SMS gateway with some API. Using javax.mail is straightforward as long as you have access to a SMTP host allowing anonymous access. A flexible publish-subscribe mechanism for 2) can be used to connect 1) and 3).

stili
A: 

here is a good article with sample code for using jms in your app to raise alerts link text. once you have that working with local monitoring you need to set the -Dom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false so that you can connect from a remote machine. a nice simple program to monitor jmx enabled java which can plot webpages of moving graphs and email out alerts when thresholds change is link text. it will also let you remote control your apps via the webpages. nice and simple. of course if you are using jmx you can easily swap up to use something more complex such as nagios or some expensive commercial tool. the key points about those tools is that they have workflow and rotas and stuff to manage a big team of people wanting to look after lots of things (databases, servers, java, etc) - which may be too much complexity if you just starting out with getting the java side of jmx working.

simbo1905