Currently in JBoss messaging the messages aren't removed from the in-memory message cache when the number of references referencing them reaches zero, causing a mem leak.
Also the message is not remove from the db for the same reason.
I've been considering how to implement a referencing counting mechanism to solve this.
For the in-memory message case is seems fairly straightforward, messages should be removed from the in-memory cache when there are no references in that jms node referencing them.
However the second case seems more difficult, since JBoss Messaging is not an HA singleton, the message reference may have been passed to another node in the cluster so I don't want to delete the row if there are no references in just one node.
Hmmm.. Does this mean we need a global ref count for the message across the cluster. Sounds like this could get messy.... ?
We're going to park the distributed problem for now, and make the restriction that message refs are never passed outside the jms node.
This makes our life a lot easier