transactional queue

T

tringuyen99

Hi,

I'm trying to look for a transactional queue implementation.
From what I understand, during the dequeue operation, a commit doesn't
happen until the client code calls commit eventhough the client code
uses the elements it has dequeued but not yet committed.

Tri
 
B

bob

Facets™ is an object oriented database that provides transactional,
easy to implement, highly scalable transparent persistence by
reachability for native Java™ objects. Facets includes a class
called CuQueue. Objects can be added to the CuQueue at one end by one
or more sessions (called "producers"). Objects can be consumed at the
other end in FIFO order by a single concurrent session (called the
"consumer"). There can be multiple consumers, but not concurrently. The
consumer can also be a producer during the same transaction.

More details about Facets and a free download are available at
http://www.facetsodb.com
 
S

Stefan Schulz

What should, in your opinion, happen if two threads request an object
concurrently, before either commits to dequeuing it?

[A, B, C]

Thread a:
poll(); <--- Will receive A

/* do stuff */

commit();

Thread b:
poll() <--- What should it receive, if calling between poll() and
commit?
 
B

bob

The Facets oodb by default uses optimistic concurrency with each
transaction being given a guaranteed view of the database (it does not
see changes made by another transaction until that transaction
commits). So in the example you described with both threads a and b
starting from the same transactional view of the database the first
thread to commit (thread a) wins and removes object A. Thread b also
attempts to remove A (because it has the same view), but it fails in
the consistency checks at commit.

If you want to have multiple consumers from the queue there are at
least two solutions:
1. Use the ObjectLocking feature to serialize the consumers.
2. Use multiple CuQueues (one for each Consumer thread) with some
other heuristic of the application being used by the producers
to determine which queue to put their entries in.

A CuQueue is a Java class which provides a queue interface but is
implemented with behavioral concurrency control. The behavioral
concurrency control allows multiple producers to run concurrently with
a single consumer with no transaction conflicts. Therefore, using a
CuQueue for each consumer thread allows the construction of a system in
which multiple producers and consumers are able to run concurrently
with no transaction conflicts. This solution is better than the
pessimistic approach (using ObjectLocks) because it doesn't force the
serialization of the threads that are servicing the queue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top