public abstract class BlockingWaiter<T> extends Object
BlockingWaiters are used to coordinate when waiting for an an event that expect a response. They are always used in a 'one-shot' manner, that is, to receive just one response. Usually the caller has to register them as method listeners with an event dispatcher and remember to de-register them (in a finally block) once they have been completed.
The process(T)
must return true on any incoming method that it handles. This indicates to
this listeners that the object just processed ends the waiting process.
Errors from the producer are rethrown to the consumer.
TODO Interruption is caught but not handled. This could be allowed to fall through. This might actually be useful for fail-over where a thread is blocking when failure happens, it could be interrupted to abandon or retry when this happens. At the very least, restore the interrupted status flag.
TODO If the retrotranslator can handle it, could use a SynchronousQueue to implement this rendezvous. Need to check that SynchronousQueue has a non-blocking put method available.
Constructor and Description |
---|
BlockingWaiter() |
Modifier and Type | Method and Description |
---|---|
Object |
block(long timeout)
Blocks until an object is received that is handled by process, or the specified timeout
has passed.
|
void |
close()
Close this Waiter so that no more errors are processed.
|
void |
error(Exception e)
This is a callback, called when an error has occurred that should interrupt any waiter.
|
abstract boolean |
process(T object)
Delegates processing of the incoming object to the handler.
|
boolean |
received(T object)
An Object has been received and should be processed to see if our wait condition has been reached.
|
public abstract boolean process(T object)
object
- The object to process.public boolean received(T object)
object
- The object received.public Object block(long timeout) throws QpidException, FailoverException
timeout
- The timeout in milliseconds.QpidException
FailoverException
public void error(Exception e)
e
- The exception being propagated.public void close()
Copyright © 2006–2016 The Apache Software Foundation. All rights reserved.