Package org.zeromq
Interface ZAgent
-
- All Known Implementing Classes:
ZActor,ZAgent.SimpleAgent,ZStar
public interface ZAgentFirst implementation of an agent for a remotely controlled background service for ØMQ. Used in conjunction with a ZStar, but not mandatory.An agent is a mechanism allowing to send messages from one thread to another, and to receive messages from this other thread.
Its built-in implementation provides an easy communication-lock system that will close the access once the remote thread is finished.
Are proposed for you a restrained set of simple but powerful messaging commands for a quick learning curve and an access to the underlying Socket for advanced usage.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classZAgent.Creatorstatic interfaceZAgent.SelectorCreatorDeprecated.static classZAgent.SimpleAgentCreates a very simple agent with an easy lock mechanism.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Closes the pipe.ZMQ.Socketpipe()Returns the socket used for communication.ZMsgrecv()Receives a control message sent from the Plateau in the Corbeille.ZMsgrecv(boolean wait)Receives a control message sent from the Plateau in the Corbeille.ZMsgrecv(int timeout)Receives a control message sent from the Plateau in the Corbeille.booleansend(java.lang.String word)Sends a control message from the Corbeille to the Plateau side.booleansend(java.lang.String word, boolean more)Sends a control message from the Corbeille to the Plateau side.booleansend(ZMsg message)Sends a control message from the Corbeille to the Plateau.booleansend(ZMsg msg, boolean destroy)Sends a control message from Corbeille side to the Plateau side.booleansign()Gives a sign if the distant Star is here.
-
-
-
Method Detail
-
recv
ZMsg recv()
Receives a control message sent from the Plateau in the Corbeille. The call is blocking.- Returns:
- the received message or null if the context was shut down.
-
recv
ZMsg recv(int timeout)
Receives a control message sent from the Plateau in the Corbeille. The call times out if there is no message after the elapsed time.- Parameters:
timeout- the timeout in milliseconds before returning null.- Returns:
- the received message or null if the context was shut down or if no message after the timeout.
-
recv
ZMsg recv(boolean wait)
Receives a control message sent from the Plateau in the Corbeille. The call is blocking depending on the parameter.- Parameters:
wait- true to make a blocking call, false to not wait, and possibly return null- Returns:
- the received message or null if the context was shut down or if there is no message when not blocking.
-
send
boolean send(ZMsg message)
Sends a control message from the Corbeille to the Plateau.- Parameters:
message- the message to send- Returns:
- true if the message was sent, otherwise false (if the distant Star is dead for example)
-
send
boolean send(ZMsg msg, boolean destroy)
Sends a control message from Corbeille side to the Plateau side.- Parameters:
msg- the message to senddestroy- true to destroy the message after sending it.- Returns:
- true if the message was sent, otherwise false (if the distant Star is dead for example)
-
send
boolean send(java.lang.String word)
Sends a control message from the Corbeille to the Plateau side.- Parameters:
word- the message to send- Returns:
- true if the message was sent, otherwise false (if the distant Star is dead for example)
-
send
boolean send(java.lang.String word, boolean more)Sends a control message from the Corbeille to the Plateau side.- Parameters:
word- the message to sendmore- true to send more strings in a single message- Returns:
- true if the message was sent, otherwise false (if the distant Star is dead for example)
-
sign
boolean sign()
Gives a sign if the distant Star is here.- Returns:
- true if here, otherwise false
-
pipe
ZMQ.Socket pipe()
Returns the socket used for communication. For advanced usage.- Returns:
- the socket used to communicate with the distant Star.
-
close
void close()
Closes the pipe.
-
-