blob: 9608e4b1c890285ea21277540e2be235ba67de11 [file] [log] [blame]
<div class="wiki-content maincontent"><p>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 <code>getConnection()</code>.</p><h2 id="ConfigurableIOExceptionHandling-DefaultIOExceptionhandler">Default IOException handler</h2><p>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.</p><p>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.</p><p>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.</p><h3 id="ConfigurableIOExceptionHandling-ConfiguringDefaultIOExceptionhandler">Configuring Default IOException handler</h3><p>There are a couple of properties you can use to tune the behavior of the <code>DefaultIOExceptionHandler</code>. First, instantiate the exception handler as a bean. Then configure the broker to use the exception handler by setting the broker's <code>ioExceptionHandler</code> property.</p><p>Example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"> &lt;bean id="ioExceptionHandler" class="org.apache.activemq.util.DefaultIOExceptionHandler"&gt;
&lt;property name="ignoreAllErrors"&gt;&lt;value&gt;true&lt;/value&gt;&lt;/property&gt;
&lt;/bean&gt;
&lt;broker xmlns="http://activemq.apache.org/schema/core" ioExceptionHandler="#ioExceptionHandler"&gt;
...
&lt;/broker&gt;
</pre>
</div></div><p>Handler configuration properties:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Property</p></th><th colspan="1" rowspan="1" class="confluenceTh">Since</th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>ignoreAllErrors</code></p></td><td colspan="1" rowspan="1" class="confluenceTd">5.4</td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>When <code>true</code> all errors are ignored and the broker remains running.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>ignoreNoSpaceErrors</code></p></td><td colspan="1" rowspan="1" class="confluenceTd">5.4</td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>When <code>false</code> 'no disk space' errors are treated the same as other errors causing the broker to be stopped.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>noSpaceMessage</code></p></td><td colspan="1" rowspan="1" class="confluenceTd">5.4</td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>space</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The string used to match against the exception's message. When matched a 'no disk space' error results.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><span style="color: rgb(0,0,0);"><code>ignoreSQLExceptions</code></span></p></td><td colspan="1" rowspan="1" class="confluenceTd">5.5</td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If <code>true</code> all SQLExceptions are ignored by the handler allowing them to be handled by the persistence adapter's locker. When <code>false</code> the exception handler processes the exception.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><span style="color: rgb(0,0,0);"><code>sqlExceptionMessage</code></span></p></td><td colspan="1" rowspan="1" class="confluenceTd">5.5</td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>""</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The SQLException phrase to match when ignoring SQLExceptions. Only matched exceptions are ignored. All SQLExceptions match the default empty string.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><span style="color: rgb(0,0,0);"><code>stopStartConnectors</code></span></p></td><td colspan="1" rowspan="1" class="confluenceTd">5.5</td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>When <code>true</code> 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.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><span style="color: rgb(0,0,0);"><code>resumeCheckSleepPeriod</code></span></p></td><td colspan="1" rowspan="1" class="confluenceTd">5.5</td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>5sec</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The interval between persistence adapter checkpoints. Typically used in conjunction with <code>stopStartConnectors</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><span style="color: rgb(0,0,0);">systemExitOnShutdown</span></p></td><td colspan="1" rowspan="1" class="confluenceTd">5.13</td><td colspan="1" rowspan="1" class="confluenceTd">false</td><td colspan="1" rowspan="1" class="confluenceTd"><span style="color: rgb(0,0,0);">before stopping the broker, set the broker attribute <span style="line-height: 1.42857;">systemExitOnShutdown to this value to potentially force a jvm exit. </span></span></td></tr></tbody></table></div><p><span style="color: rgb(0,0,0);">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 <code style="line-height: 1.42857;">noSpaceMessage</code> property.</span></p><p>Note: as of ActiveMQ 5.11 the <code>JDBCIOExceptionHandler</code> has been deprecated. It has been replaced by the <code>org.apache.activemq.util.LeaseLockerIOExceptionHandler</code> that will work with any persistence adapter that supports pluggable storage lockers whether or not a locker is in use.</p><p><span style="color: rgb(102,0,51);">Writing your own handler</span></p><p>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 <code>df</code> on Linux to be sure.</p><p>All you have to do is implement the <code>org.apache.activemq.util.IOExceptionHandler</code> interface then configure the broker to use it:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"> &lt;bean id="ioExceptionHandler" class="com.mycompany.MyIOExceptionHandler"&gt;
&lt;property name="ignoreAllErrors"&gt;&lt;value&gt;true&lt;/value&gt;&lt;/property&gt;
&lt;/bean&gt;
&lt;broker xmlns="http://activemq.apache.org/schema/core" ioExceptionHandler="#ioExceptionHandler"&gt;
...
&lt;/broker&gt;
</pre>
</div></div></div>