|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object kaos.core.service.transport.tcp.TCPMessageReceiver
public class TCPMessageReceiver
MessageReceiver is an endpoint created by a transport service. It is used as the means by which messages enter the agent. The agent can either receive message synchronously (via polling getMessage) or asynchronously (via the MessageListener callback). Prior to messaging use, the MessageReceiver must be bound to a local locator.
When using the MessageReceiver in a polling fashion the number of messages present (awaiting delivery) can be myEnumerated (count). The waiting message can be received by invoking one of the getMessage() methods.
MessageTransportService
,
TransportSystem
,
Serialized FormConstructor Summary | |
---|---|
TCPMessageReceiver()
Testing constructor |
|
TCPMessageReceiver(MessageTransportService transportService)
Normal constructor |
Method Summary | |
---|---|
void |
acceptMessage(byte[] msg)
|
void |
addMessageListener(MessageListener ml)
Adds a MessageListener to the MessageReceiver for asynchronous message delivery. |
void |
bindToLocalLocator(Locator loc)
The method which binds the MessageReceiver to a local locator. |
Locator |
getLocalLocator()
Returns a local locator depending upon binding status. |
TransportMessage |
getMessage()
A blocking read operation. |
TransportMessage |
getMessage(long wait_millis)
A timed blocking read operation. |
MessageTransportService |
getMessageTransportService()
|
int |
getNumberOfMessages()
The number returned does not guarantee the actual number of messages available instantaneously. |
static void |
main(java.lang.String[] args)
|
void |
removeMessageListener(MessageListener ml)
Removes a MessageListener from the MessageReceiver. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TCPMessageReceiver(MessageTransportService transportService)
public TCPMessageReceiver()
Method Detail |
---|
public MessageTransportService getMessageTransportService() throws TransportFailure
TransportFailure
public void bindToLocalLocator(Locator loc) throws NotLocatableException, TransportFailure
l
- the local Locator.
NotLocatableException
- if l is not a local locator.
TransportFailure
- if the binding process fails.public Locator getLocalLocator() throws TransportFailure
TransportFailure
- if any transport related failure occurs.public int getNumberOfMessages() throws TransportFailure
TransportFailure
- if any transport related failure occurs.public TransportMessage getMessage() throws java.lang.InterruptedException, TransportFailure
java.lang.InterruptedException
- if the waiting thread is interrupted.
TransportFailure
- if any transport related failure occurs.public TransportMessage getMessage(long wait_millis) throws java.lang.InterruptedException, TransportFailure
wait_millis
- the most the current thread should block for a message.
java.lang.InterruptedException
- if the waiting thread is interrupted.
TransportFailure
- if any transport related failure occurs.public void addMessageListener(MessageListener ml) throws TransportFailure
ml
- the MessageListener to callback with the incoming message.
TransportFailure
- if any transport related failure occurs.public void removeMessageListener(MessageListener ml) throws TransportFailure
ml
- the MessageListener to remove from the MessageReceiver.
TransportFailure
- if any transport related failure occurs.public void acceptMessage(byte[] msg)
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |