Constructor and Description |
---|
ServerReceiver() |
Modifier and Type | Method and Description |
---|---|
void |
receiveFrom(Acceptor acceptor,
ConnectionType[] connectionTypes,
int numberOfThreads,
long idleThreadPollDelay,
long inactiveClientTimeOut)
Registers a new
Acceptor from which the ServerReceiver
should process messages. |
void |
shutdown()
Shut down this receiver.
|
Message |
waitForMessage()
Block until a message is available, or another thread has called
shutdown() . |
public void receiveFrom(Acceptor acceptor, ConnectionType[] connectionTypes, int numberOfThreads, long idleThreadPollDelay, long inactiveClientTimeOut) throws CommunicationException
Acceptor
from which the ServerReceiver
should process messages. Actively polls connections of the given types for
messages, de-serialises them, and queues them for retrieval using
waitForMessage()
.
A single ServerReceiver
can listen to messages from multiple
Acceptor
s. You can register the same Acceptor
with
multiple ServerReceiver
s, but then there is no way of
controlling which receiver will receive messages from a given
Acceptor
.
acceptor
- Acceptor.connectionTypes
- Type of connections to listen for.numberOfThreads
- How many threads to dedicate to processing the Acceptor. The
threads this method spawns just read, deserialise, and queue. Set
numberOfThreads
to the number of concurrent streams
you expect to be able to read.idleThreadPollDelay
- Time in milliseconds that an idle thread should sleep if there are
no sockets to process.inactiveClientTimeOut
- How long before we consider a client connection that presents no
data to be inactive.CommunicationException
- If this ServerReceiver
has been shutdown.public Message waitForMessage() throws CommunicationException
shutdown()
. Typically called from a message dispatch loop.
Multiple threads can call this method, but only one thread will receive a given message.
waitForMessage
in interface Receiver
null
if shut down.CommunicationException
- If an error occurred receiving a message.Copyright © 2000-2014. All Rights Reserved.