public class MessageAsync<M extends Message> extends SingleSender<M> implements MessageReceiver<M>
SingleSender
which lets the drain's receive method
run asynchronouously in a separate thread. MessageReceiver.receive(Message)
method of the current drain
is executed in a loop in an own, specially constructed
Thread
, consuming all these messages asynchronouously.receive(Message)
thus returns immediately,
after writing the message into a buffer object.
(This is currently a LinkedBlockingQueue
.)receiver
Constructor and Description |
---|
MessageAsync()
After calling this constructor, a call to
SingleSender.setReceiver(MessageReceiver)
is necessary before you can use SingleSender.send(Message) . |
MessageAsync(MessageReceiver<? super M> r) |
Modifier and Type | Method and Description |
---|---|
void |
receive(M m)
Returns immediately after storing the message to the internal buffer.
|
getReceiver, send, setReceiver
public MessageAsync()
SingleSender.setReceiver(MessageReceiver)
is necessary before you can use SingleSender.send(Message)
.
Otherwise code will crash intentionally.
Cf the documentation of
the super constructor
.public MessageAsync(MessageReceiver<? super M> r)
public void receive(M m)
Integer.MAX_VALUE
messages.receive
in interface MessageReceiver<M extends Message>
see also the complete user documentation .