I have to persist of flow of continuously incoming messages. For performance reasons, I wait until I have a reasonable set of messages before sending them to the database. I keep these messages that are to be persisted in a collection C. I get notified by JMS whenever a message is added in the database.
I'd like to make a query on both the objects present in the database and the ones that are in C.
Is there a common design pattern to solve this issue ? Do I have to keep a copy of the database in a collection in memory ? If I try to read the contents of the database, and then the contents of C, and then put them together to make my query on this fusion, how can I make sure that while doing that another thread has not emptied C and put it in the database ?
Thanks
I'd like to make a query on both the objects present in the database and the ones that are in Cwhat do you mean by this? elaborate a little.