Search code examples
javanotificationsjmxalerts

Can we use JMX for Alerts/Notification


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.


Solution

  • 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.