title: Database failure shuts down ActiveMQ windows service using JDBC persistence
body: <p>I have an ActiveMQ broker running as a Windows service. Its using <em>jdbcPersistenceAdapter</em> with Oracle data source and Oracle's Universal Connection Pooling (UCP).</p>
  
  <p>When the database is down (due to network problems or scheduled maintenance), the ActiveMQ windows service shuts down completely. This, of course makes the broker unavailable even after the database is restored.</p>
  
  <p>I have tried connection validation in UCP, DBCP with connection validation and even MySQL data source without any success. The service shuts down within 30 seconds of database failure (I believe this is because the default <em>cleanupInterval</em> is 30 seconds).</p>
  
  <p>Is there a way to <strong>prevent the windows service from shutting down</strong> and make it wait for database availability?
  Any help is greatly appreciated.</p>
  
  <p>Here is my current configuration from activemq.xml:</p>
  
  <pre><code>&lt;persistenceAdapter&gt;
      &lt;jdbcPersistenceAdapter dataSource="#oracle-ds"/&gt;
  &lt;/persistenceAdapter&gt;
  
  &lt;bean id="oracle-ds" class="oracle.ucp.jdbc.PoolDataSourceFactory" 
      factory-method="getPoolDataSource" p:URL="jdbc:oracle:thin:@localhost:1521:amq" 
      p:connectionFactoryClassName="oracle.jdbc.pool.OracleDataSource" 
      p:validateConnectionOnBorrow="true" p:user="appuser" p:password="userspassword" /&gt;
  </code></pre>