Saturday, April 29, 2006

File Store Persistence for ActiveMQ

I've recently been working on a file based persistent store (called Kaha) for the ActiveMQ messaging project. There were a couple of reasons for doing this:

  • firstly we are about to re-architect the message dispatching for persistent messages, so having something with a simple interface (Collections) would enable some rapid prototyping
  • It's got to be compatible with the Apache licence - ruling out some well known alternatives
  • I wanted to see if I could provide a faster persistent engine than the current ones we use in ActiveMQ.
For messaging systems, the general pattern for persistence is that messages are short lived in the store - being written and deleted extremely quickly. Messages only tend to be read for message consumers that haven't been active for a while (or slow consumers - when messages are read from the store so as not to constrain other consumers).

Persisted messages are generally read in insertion order, but also need to be accessed by their id so they can be deleted (message acknowledgements can be received out of order - e.g. for Queues). So using a mixture of persistent Maps and Lists from the developers view is ideal.

The Kaha persistence adaptor is available in the latest snapshot of ActiveMQ, though we are not going to push this as a new feature until the 4.1 release. But if you're brave enough - give it a try :)