jAlarms

Welcome to the jAlarms project. You can look at the Javadoc reference, or go to the project page for downloads, submit bugs, etc.

IMPORTANT: Starting with 1.6.0, jAlarms is composed of modules:

core
This contains the core classes, along with some channels that have no external dependencies. This is usually the only module you need at development time.
channels
This contains channel implementations which need external dependencies, as well as other classes that have external dependencies (such as the memcached cache).
aop
This contains the classes and annotations needed to use jAlarms in an AOP manner.
protobuf
This contains a couple of components to implement a remote alarm service in which clients send alarms to the server via Protocol Buffers messages.
remote
This contains components that can listen to incoming connections for different protocols, to receive alarm requests and send them via a configured AlarmSender.
groovy
This contains a component that adds new methods to an AlarmSender at runtime, to send an alarm if an exception is thrown within a closure in Groovy.
scala
This adds new methods to an AlarmSender that send an alarm if an exception is thrown inside a closure in Scala. []

An important change from jAlarms 1.5 is that AlarmSender is now an interface, and the class that implements it is now called AlarmSenderImpl. This change will allow an AlarmSender to be published as a service via different means such as RMI or RPC.

Goal

The goal of this project is to provide Java application developers with a tool to easily implement an alarm mechanism on server applications. Server applications usually have to be monitored constantly to check for any problems, but sometimes a condition arises (like some exception that you know only happens as the result of something very bad) that someone should know about ASAP. So instead of having to write and test a bunch of code to send an email notification or a SMS to the sysadmin, you can just use this library.

How it works

This diagram shows how jAlarms works; it's very simple. Your components invoke the sendAlarm() method on the AlarmSender component, which in turn sends the corresponding alarm messages through its available channels. You can create your own custom channels or just use the ones included with the library, configuring them the way it best fits your application.

Basic diagram depicting the way jAlarms works

Example

Suppose you have an email account set up just to send alarm notifications. You can also have a MSN account for the same purpose. So now you set up an AlarmSender with a MsnChannel and a MailChannel; you inject this AlarmSender into any component that might need to send an alarm, and then your code could look like this:

private AlarmSender alarmer;
.
.
.
try {
    //your code goes here
} catch (SomeException ex) {
    //here goes whatever you need to do to handle SomeException
    //then you send the alarm
    alarmer.sendAlarm("OMG the sky is falling", null);
}

The message OMG the sky is falling will be sent via email to the recipients configured in the MailChannel, and also to everyone in the contact list of the account used by the MsnChannel.

If you later have access to some other service, like a SMPP server, you can configure the SmppChannel and add it to the channels used by the AlarmSender, so that now the right people can receive notification via SMS on their mobile devices, and you don't have to change anything in the application code, just the configuration of the AlarmSender, which can be easily managed by Spring (optional).

Here you can find an example of jAlarms configuration with Spring.

Software License

jAlarms is distributed under the LGPL version 2.1. The full text for this license can be found here.