[Prevayler-discussion] Prevayler + BlockingQueue
Brought to you by:
jsampson,
klauswuestefeld
From: Attila M. <m.m...@gm...> - 2016-08-24 11:21:23
|
Hi, I tried to use Prevayler on a Java BlockingQueue in a naive way, and it didn't work the way I expected. I guess I see the reason why, but I'm still not sure how should I use it. Here is an example code I wrote it https://gist.github.com/zeroflag/8c7333e96ab9b8c8a09fa0a3b08bb907 There are 2 commands. AddDocument adds a new document to the queue, TakeDocument removes a document from the queue. Both operations blocks the current thread, and probably this is the problem. I assume prevayler uses locks on each transactions therefore taking document from an empty queue blocks other threads from adding a new document. My goal is to have a simple persistent (blocking) queue. Is there any simple way to make this work, or what other options do I have? thanks Attila |