If you are getting an error while starting ActiveMQ something like this
2012-09-13 18:23:39,823 | ERROR | Failed to start ActiveMQ JMS Message Broker. Reason: java.io.IOException: Detected missing/corrupt journal files. 1 messages affected. | org.apache.activemq.broker.BrokerService | main
java.io.IOException: Detected missing/corrupt journal files. 1 messages affected.
at org.apache.activemq.store.kahadb.MessageDatabase.recoverIndex(MessageDatabase.java:626)
at org.apache.activemq.store.kahadb.MessageDatabase$6.execute(MessageDatabase.java:460)
at org.apache.kahadb.page.Transaction.execute(Transaction.java:728)
at org.apache.activemq.store.kahadb.MessageDatabase.recover(MessageDatabase.java:458)
at org.apache.activemq.store.kahadb.MessageDatabase.open(MessageDatabase.java:315)
at org.apache.activemq.store.kahadb.MessageDatabase.load(MessageDatabase.java:357)
at org.apache.activemq.store.kahadb.MessageDatabase.doStart(MessageDatabase.java:222)
at org.apache.activemq.store.kahadb.KahaDBStore.doStart(KahaDBStore.java:180)
at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:53)
at org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter.start(KahaDBPersistenceAdapter.java:186)
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:485)
at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
---
solution is :
Sometime kahaDB which is used by activeMQ to persist the message, get either corrupted some message/journal gets corrupted or missing. I got few flag which can can configured in activemq.xml.
<persistenceAdapter>
<kahaDB directory="${activemq.base}/data/kahadb"
ignoreMissingJournalfiles="true"
checkForCorruptJournalFiles="true"
checksumJournalFiles="true" />
</persistenceAdapter>
http://activemq.apache.org/kahadb.html
After setting these flag, start the activemq and watch it print something like this :
2012-09-13 18:33:26,144 | INFO | Recovering from the journal ... | org.apache.activemq.store.kahadb.MessageDatabase | main
2012-09-13 18:33:26,145 | INFO | Recovery replayed 1 operations from the journal in 0.326 seconds. | org.apache.activemq.store.kahadb.MessageDatabase | main
2012-09-13 18:33:29,580 | INFO | Some journal files are missing: [42658] | org.apache.activemq.store.kahadb.MessageDatabase | main
2012-09-13 18:33:29,774 | INFO | Detected missing/corrupt journal files. Dropped 1 messages from the index in 3.59 seconds. | org.apache.activemq.store.kahadb.MessageDatabase | main
Then you are done. If it still does not work. Remove the kahadb/db.data and restart, it will parse the journal to rebuild the index.
I am using 5.4.2 version of ActiveMQ, kahaDB version 3.
:)