Prevayler + BlockingQueue
Attila Magyar <[email protected]> Wed, 24 Aug 2016 13:21:16 +0200
| Newsgroups | gmane.comp.java.prevayler |
|---|---|
| Message-ID | <CAPKVUJ+PsDdfFioT=Sj45Jk7KcnD5Mu9dnxTUVySk-TV9kpxWw@mail.gmail.com> |
--===============1845398185631390692== Content-Type: multipart/alternative; boundary=001a11412038d81287053acf7ab1 --001a11412038d81287053acf7ab1 Content-Type: text/plain; charset=UTF-8 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 --001a11412038d81287053acf7ab1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hi,<div><br></div><div>I tried to use Prevayler on a Java = BlockingQueue in a=C2=A0naive way, and it didn't work the way I expecte= d. I guess I see the reason why, but I'm still not sure how should I us= e it.</div><div><br></div><div>Here is an example code I wrote it</div><div= ><br></div><div><a href=3D"https://gist.github.com/zeroflag/8c7333e96ab9b8c= 8a09fa0a3b08bb907">https://gist.github.com/zeroflag/8c7333e96ab9b8c8a09fa0a= 3b08bb907</a><br></div><div><br></div><div>There are 2 commands. AddDocumen= t adds a new document to the queue, TakeDocument removes a document from th= e queue. Both operations blocks the current thread, and probably this is th= e problem. I assume prevayler uses locks on each transactions therefore tak= ing document from an empty queue blocks other threads from adding a new doc= ument.</div><div><br></div><div>My goal is to have a simple persistent (blo= cking) queue.</div><div><br></div><div>Is there any simple way to make this= work, or what other options do I have?</div><div><br></div><div>thanks</di= v><div>Attila</div><div><br></div><div><br></div></div> --001a11412038d81287053acf7ab1-- --===============1845398185631390692== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ --===============1845398185631390692== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion _______________________________________________ "Databases in Memoriam" -- http://www.prevayler.org --===============1845398185631390692==--