I have a Gemfire application where I am performing DB updates to cached objects inside an AsyncEventListener. Basically whenever an object is put into Gemfire the AsyncEventListener will fire and the DB update will be performed. I want to multithread the db update logic inside of the AsyncEventListener so that multiple puts to different objects in the same region will be written down to the DB in parallel. In my understanding of the AsyncEventListener events will not get taken out of the processing queue until the processEvents(...) method returns true so that if, for example, the node goes down before the method returns true the events will be preserved for future processing. By spawning an asynchronous thread to handle the event, however, I lose this ability to preserve events in the queue since the method will return true without hearing back from the processing thread. My fear is that if the node goes down while the processing thread is working I will potentially lose the DB update of that object.
My questions are:
- Is my understanding of the AsyncEventListener/Queue correct?
- If I'm correct what is the recommended way to deal with this scenario so that I can preserve all events?