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 getConnection().
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 default IOException handler. But first you need to configure the broker to use customized handler. You can do that by instantiating a handler and setting it using
Here are the properties
ignore all errors and don't stop the broker
if set to false, 'no disk space' errors will not be treated separately and broker will be stopped
try to find this phrase in exception message to determine if it is 'no disk space' case
SLQExceptions that match (default all) will be ignored. This allows the existing database locker to take control of DB failures. When false the handler will process the exception
The SQLException phrase to match when ignoring SQLExceptions. Only exceptions that match are ignored. Everything matches the default empty string
Don't stop the broker, just stop and restart the transport connectors when a persistence adapter checkpoint succeeds again. While the handler is waiting to restart the connectors exceptions are ignored. Using this option ensures that the broker does not need to be manually restarted in the event of a DB restart
the sleep period between checks for a successful persistence adapter checkpoint that allows transport connectors to resume. used in conjunction with stopStartConnectors
Options in red are available in version 5.5
The default configuration will try to find a specified string in the exception message to determine whether it is a 'no disk space' kind of error. On most platforms (at least those we have tested), you'll find the 'space' word in it. Of course, you can customize this to your platform using
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 and configure the broker to use it