There is a message loss of persisted messages in latest ActiveMQ, using AMQ Persistent Store. The following test case for both 5.3.0.1-fuse and 5.4.2-fuse-01-00 exemplifies the problem. Here's the broker configuration:
<beans
xmlns="http:
xmlns:amq="http:
xmlns:xsi="http:
xsi:schemaLocation="
http: http: http: http:
<broker xmlns="http:
brokerName="localhost"
dataDirectory="${activemq.base}/data"
destroyApplicationContextOnStop="true">
<managementContext>
<managementContext createConnector="true" connectorPort="2010"/>
</managementContext>
<persistenceAdapter>
<amqPersistenceAdapter directory="activemq-data" maxFileLength="1mb"
directoryArchive="activemq-data-archive" archiveDataLogs="true"
recoverReferenceStore="true"/>
</persistenceAdapter>
<transportConnectors>
<transportConnector name="openwire" uri="tcp:/>
</transportConnectors>
</broker>
</beans>
Then, run the following script to populate the AMQ Store data logs. This script has been carefully thought out to leave a message in data-1, the first log file. Note that the script should be run in the ActiveMQ examples/ directory.
call ant -Dsubject=Store1 -Ddurable=true -Dmax=1 producer
call ant -Dsubject=Store2 -Ddurable=true -Dmax=1 producer
call ant -Dsubject=Store3 -Ddurable=true -Dmax=200 -DmessageSize=5000 producer
call ant -Dsubject=Store2 -Ddurable=true -Dmax=1 consumer
call ant -Dsubject=Store3 -Ddurable=true -Dmax=200 -DmessageSize=5000 producer
call ant -Dsubject=Store3 -Ddurable=true -Dmax=400 consumer
After running this script, you should see 3 data files in the AMQ Store journal directory.
Now, shutdown the broker, and delete the KR indices (activemq-data/kr-store/*).
On restart, the AsyncDataManager thread will go through the data files, and errantly determine that data-1 has no references. It moves data-1 to the archive directory. As a result, we see that the message we sent to queue 'Store1' is missing.
Only deleting the "state" folder in activemq-data/kr-store/ resolves this issue, however, the customer would like to see the use case work when deleting the entire kr-store file.