Starting with 5.3.1, ActiveMQ provides configurable IOException handling for its file-based message stores. From version 5.5 the handler is also invoked when the JDBC persistence adapter gets a failure on
Default IOException handler
ActiveMQ comes with a default IOException handler, which does the following. When some of the file-based message stores encounter IOException it can be one of the two things: either the disk is unavailable of there's no more space on the disk.
The first case is usually encountered when disk fails or network disk is disconnected. These errors are not "recoverable" and we usually want to shutdown the broker until problems with the disk are solved.
When there's no more space on the disk, we usually want to wait that some space is reclaimed and continue what we have been doing before (exchanging messages). All file-based persistent stores are capable of surviving these kind of errors.
Configuring Default IOException handler
There are a couple of properties you can use to tune the behavior of the
DefaultIOExceptionHandler. First, instantiate the exception handler as a bean. Then configure the broker to use the exception handler by setting the broker's
Handler configuration properties:
The string used to match against the exception's message. When matched a 'no disk space' error results.
The SQLException phrase to match when ignoring SQLExceptions. Only matched exceptions are ignored. All SQLExceptions match the default empty string.
The interval between persistence adapter checkpoints. Typically used in conjunction with
|5.13||false||before stopping the broker, set the broker attribute systemExitOnShutdown to this value to potentially force a jvm exit.|
The default configuration will try to find a specified string in the exception message to determine whether it is a 'no disk space' error. On most platforms (at least those we have tested), you'll find the word 'space' in it. Of course, you can customize this to your platform by using
Note: as of ActiveMQ 5.11 the
JDBCIOExceptionHandler has been deprecated. It has been replaced by the
org.apache.activemq.util.LeaseLockerIOExceptionHandler that will work with any persistence adapter that supports pluggable storage lockers whether or not a locker is in use.
Writing your own handler
In case this handler doesn't work for you, you can write your own. For example you might want to change the way how you detect full disk and execute some external command, like
df on Linux to be sure.
All you have to do is implement the
org.apache.activemq.util.IOExceptionHandler interface then configure the broker to use it: