Re: JavaSpace.notify() "not reliable"

Gregg Wonderly <[email protected]> Sat, 12 May 2007 23:11:50 -0500
Newsgroups gmane.comp.java.sun.javaspaces
Message-ID <[email protected]>
Dan Creswell wrote:
> Timur Mehrvarz wrote:
>>On 11.05.2007, at 05:19, Gregg Wonderly wrote:
>>>Are you using the returned value from notify to get the associated Lease,
>>
>>Yes.
>>
>>>and then passing that off to a LeaseRenewalManager, or otherwise
>>>renewing it?
>>
>>I do not renew my Lease. I usually need to apply a different search
>>template, everytime I call notify(). So I cancel() the lease, take() the
>>object from space, start a new notify() and do a wait(). I can see how
>>the worker thread is always calling the notify(), before the master
>
> How have you confirmed and/or guarenteed that the master writes the
> object into the space after the notify()?

As a general rule of listener use, anytime you add a listener for some kind of
notify, you need to query with the same template that the listener has to make
sure that there was no item added between the last notify/query and the next
notify registration.  Odd things can really happen in distributed systems.

With service lookup and the DiscoveryListener, a serviceDiscovered() call,
should always request notification first, and then query with the
ServiceTemplate.  You may thus see the service "twice", but if you do not do
this, a service can be added in the "gap" if you query first and request notify
second.

With Javaspaces, you should typically request notification, and then do a read
to see if there is an entry that matches the same template, and then take that
entry to process it if so.

Gregg Wonderly

===========================================================================
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