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
...
There are a couple of properties you can use to tune the behavior of default IOException handler. But first you need to the DefaultIOExceptionHandler. First, instantiate the exception handler as a bean. Then configure the broker to use customized handler. You can do that by instantiating a handler and setting it using the exception handler by setting the broker's ioExceptionHandler property.
Example:
Code Block |
|
|
<bean id="ioExceptionHandler" class="org.apache.activemq.util.DefaultIOExceptionHandler">
<property name="ignoreAllErrors"><value>true</value></property>
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" ioExceptionHandler="#ioExceptionHandler">
...
</broker>
|
Here are the Handler configuration properties:
| Property |
Default Value |
Description |
| ignoreAllErrors |
false |
ignore When true all errors are ignored and don't stop the broker remains running. |
| ignoreNoSpaceErrors |
true |
if set to When false, 'no disk space' errors will not be treated separately and broker will be stopped are treated the same as other errors causing the broker to be stopped. |
| noSpaceMessage |
space try |
to find this phrase in exception message to determine if it is The string used to match against the exception's message. When matched a 'no disk space' case error results. |
| ignoreSQLExceptions |
true |
SLQExceptions that match (default all) will be ignored. This allows the existing database locker to take control of DB failuresIf true all SQLExceptions are ignored by the handler allowing them to be handled by the persistence adapter's locker. When false the exception handler will process processes the exception. |
| sqlExceptionMessage |
"" |
The SQLException phrase to match when ignoring SQLExceptions. Only matched exceptions that match are ignored. Everything matches All SQLExceptions match the default empty string. |
| stopStartConnectors |
false |
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 When true transport connectors are stopped (client connections are refused), however, the broker will remain running. The transport connectors will be restarted following a successful persistence adapter checkpoint. All exceptions are ignored whilst the transport connectors are stopped. This option ensures that the broker does not need to be manually restarted in the event of a DB restart, for example. |
| resumeCheckSleepPeriod |
5sec |
the sleep period between checks for a successful persistence adapter checkpoint that allows transport connectors to resume. The interval between persistence adapter checkpoints. Typically 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 word 'space' word in it. Of course, you can customize this to your platform by using noSpaceMessage property.
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 and then configure the broker to use it:
Code Block |
|
|
<bean id="ioExceptionHandler" class="com.mycompany.MyIOExceptionHandler">
<property name="ignoreAllErrors"><value>true</value></property>
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" ioExceptionHandler="#ioExceptionHandler">
...
</broker>
|