take()-s of two associated but distinct entries

Nirmalya Sengupta <[email protected]> Fri, 15 Sep 2006 04:22:14 -0600
Newsgroups gmane.comp.java.sun.javaspaces
Message-ID <LISTSERV%[email protected]>
Hello all,

Perhaps, this subject has been discussed before. If so, please point me
to the thread.

Suppose, there are three processes (could be threads too), interacting
through a Space. Two of them (A and B) produce Entries,
and the other (C) consumes the entries. Thorugh the Entries are
produced by two disconnected producers, there is a close assoication
betwevn them. Hence, the C need to take() the Entries together
before using them.

Producers may or may not produce entries (and write() into the space),
simultaneously. In other words, there could be a discernible time-gap
between two such write()-s. The Consumer has registered itself
for notification, for both type of entries. Obviously, there will be a
time-gap between two notifications that C gets from the Space.

So, A produces an Entry named, AE1 and write()s into the Space. C gets
the notification. Similarly, when B produces an Entry named, BE1 into
the Space, C again gets the notification. Now, C has to take AE1
and BE1.

What should C do?

a) Should C take() them under two different transactions?
b) Can C take() them under the same transactions? Will the same Txn
object work across two separate take()-s?

In a slightly different scenario, let us assume that there are two
instances of C (C1 and C2) running. A writes entries AE1 and AE2.
Similarly, B writes entries BE1 and BE2 (don't forget the time-gap).

Now, take() by either C1 or C2 has to happen in associated pairs;
in other words, whosoever takes AE1, has to take BE1 (ditto for
AE2 and BE2).

What is the most common (and efficient) pattern to be followed in such a case?

Will wait to hear from you.

Nirmalya

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff JAVASPACES-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

To view past JAVASPACES-USERS postings, please see:
http://archives.java.sun.com/archives/javaspaces-users.html