Package org.zeromq
Class ZMonitor
java.lang.Object
org.zeromq.ZMonitor
- All Implemented Interfaces:
Closeable
,AutoCloseable
The ZMonitor actor provides an API for obtaining socket events such as
connected, listen, disconnected, etc. Socket events are only available
for sockets connecting or bound to ipc:// and tcp:// endpoints.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enumerates types of monitoring events.private static class
static enum
The code returned by handshake events, as generated byeventHandshakeXXX
.static final class
High-level representation of an event. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionZMonitor
(ZContext ctx, ZMQ.Socket socket) Creates a monitoring actor for the given socket. -
Method Summary
Modifier and TypeMethodDescriptionfinal ZMonitor
add
(ZMonitor.Event... events) Adds event types to monitor.final void
close()
Stops the monitoring and closes the actor.final void
destroy()
Stops the monitoring and closes the actor.final ZMonitor.ZEvent
Gets the next event, blocking for it until available.final ZMonitor.ZEvent
nextEvent
(boolean wait) Gets the next event, blocking for it until available if requested.final ZMonitor.ZEvent
nextEvent
(int timeout) Gets the next event, blocking for it until available if requested.final ZMonitor
remove
(ZMonitor.Event... events) Removes event types from monitor.final ZMonitor
start()
Starts the monitoring.final ZMonitor
verbose
(boolean verbose) Sets verbosity of the monitor.
-
Field Details
-
started
private boolean started -
START
- See Also:
-
CLOSE
- See Also:
-
VERBOSE
- See Also:
-
ADD_EVENTS
- See Also:
-
REMOVE_EVENTS
- See Also:
-
agent
-
exit
-
-
Constructor Details
-
ZMonitor
Creates a monitoring actor for the given socket.- Parameters:
ctx
- the context relative to this actor. Not null.socket
- the socket to monitor for events. Not null.
-
-
Method Details
-
start
Starts the monitoring. Event types have to be added before the start, or they will take no effect.- Returns:
- this instance.
-
close
Stops the monitoring and closes the actor. When returning from that call, ZMonitor will be no more active.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
destroy
public final void destroy()Stops the monitoring and closes the actor. When returning from that call, ZMonitor will be no more active. -
verbose
Sets verbosity of the monitor.- Parameters:
verbose
- true for monitor to be verbose, otherwise false.- Returns:
- this instance.
-
add
Adds event types to monitor.- Parameters:
events
- the types of events to monitor.- Returns:
- this instance.
-
remove
Removes event types from monitor.- Parameters:
events
- the types of events to stop monitoring.- Returns:
- this instance.
-
nextEvent
Gets the next event, blocking for it until available.- Returns:
- the next monitored event or null if closed.
-
nextEvent
Gets the next event, blocking for it until available if requested.- Parameters:
wait
- true to block until next event is available, false to immediately return with null if there is no event.- Returns:
- the next event or null if there is currently none.
-
nextEvent
Gets the next event, blocking for it until available if requested.- Parameters:
timeout
- the time in milliseconds to wait for a message before returning null, -1 to block.- Returns:
- the next event or null if there is currently none after the specified timeout.
-