Package org.zeromq

## Class ZMQ

- java.lang.Object
- - org.zeromq.ZMQ

-     public class ZMQ
      extends Object

  ZeroMQ JNI Bindings.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `ZMQ.Context` | Inner class: Context.
    `static class` | `ZMQ.Error` | Inner class: Error.
    `static class` | `ZMQ.Event` | Inner class: Event.
    `static class` | `ZMQ.Poller` | Inner class: Poller.
    `static class` | `ZMQ.PollItem` |
    `static class` | `ZMQ.Socket` | Inner class: Socket.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `DEALER` | Flag to specify a DEALER socket (aka XREQ).
    `static int` | `DONTWAIT` |
    `static int` | `DOWNSTREAM` | Deprecated.
    `static int` | `EVENT_ACCEPT_FAILED` | EVENT_ACCEPT_FAILED: could not accept client connection.
    `static int` | `EVENT_ACCEPTED` | EVENT_ACCEPTED: connection accepted to bound interface.
    `static int` | `EVENT_ALL` | EVENT_ALL: all events known by the java binding.
    `static int` | `EVENT_BIND_FAILED` | EVENT_BIND_FAILED: socket could not bind to an address.
    `static int` | `EVENT_CLOSE_FAILED` | EVENT_CLOSE_FAILED: connection couldn't be closed.
    `static int` | `EVENT_CLOSED` | EVENT_CLOSED: connection closed.
    `static int` | `EVENT_CONNECT_DELAYED` | EVENT_CONNECT_DELAYED: synchronous connect failed, it's being polled.
    `static int` | `EVENT_CONNECT_RETRIED` | EVENT_CONNECT_RETRIED: asynchronous connect / reconnection attempt.
    `static int` | `EVENT_CONNECTED` | EVENT_CONNECTED: connection established.
    `static int` | `EVENT_DISCONNECTED` | EVENT_DISCONNECTED: broken session.
    `static int` | `EVENT_LISTENING` | EVENT_LISTENING: socket bound to an address, ready to accept connections.
    `static int` | `EVENT_MONITOR_STOPPED` | EVENT_MONITOR_STOPPED: monitor has been stopped.
    `static int` | `FORWARDER` | Flag to specify a FORWARDER device.
    `static int` | `NOBLOCK` | Socket flag to indicate a nonblocking send or recv mode.
    `static int` | `PAIR` | Flag to specify a exclusive pair of items.
    `static int` | `PUB` | Flag to specify a PUB socket, receiving side must be a SUB or XSUB.
    `static int` | `PULL` | Flag to specify the receiving part of a PUSH socket.
    `static int` | `PUSH` | Flag to specify a PUSH socket, receiving side must be a PULL.
    `static int` | `QUEUE` | Flag to specify a QUEUE device.
    `static int` | `REP` | Flag to specify the receiving part of a REQ socket.
    `static int` | `REQ` | Flag to specify a REQ socket, receiving side must be a REP.
    `static int` | `ROUTER` | Flag to specify ROUTER socket (aka XREP).
    `static int` | `SNDMORE` | Socket flag to indicate that more message parts are coming.
    `static int` | `STREAMER` | Flag to specify a STREAMER device.
    `static int` | `SUB` | Flag to specify the receiving part of the PUB or XPUB socket.
    `static int` | `UPSTREAM` | Deprecated.
    `static int` | `XPUB` | Flag to specify a XPUB socket, receiving side must be a SUB or XSUB.
    `static int` | `XREP` | Deprecated. As of release 3.0 of zeromq, replaced by `ROUTER`
    `static int` | `XREQ` | Deprecated. As of release 3.0 of zeromq, replaced by `DEALER`
    `static int` | `XSUB` | Flag to specify the receiving part of the PUB or XPUB socket.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ZMQ()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static ZMQ.Context` | `context​(int ioThreads)` | Create a new Context.
    `protected static long` | `EADDRINUSE()` |
    `protected static long` | `EADDRNOTAVAIL()` |
    `protected static long` | `ECONNREFUSED()` |
    `protected static long` | `EFSM()` |
    `protected static long` | `EHOSTUNREACH()` |
    `protected static long` | `EINPROGRESS()` |
    `protected static long` | `EMTHREAD()` |
    `protected static long` | `ENETDOWN()` |
    `protected static long` | `ENOBUFS()` |
    `protected static long` | `ENOCOMPATPROTO()` |
    `protected static long` | `ENOTSOCK()` |
    `protected static long` | `ENOTSUP()` |
    `protected static long` | `EPROTONOSUPPORT()` |
    `protected static long` | `ETERM()` |
    `static int` | `getFullVersion()` |
    `static int` | `getMajorVersion()` |
    `static int` | `getMinorVersion()` |
    `static int` | `getPatchVersion()` |
    `static String` | `getVersionString()` |
    `protected static int` | `make_version​(int major, int minor, int patch)` |
    `static int` | `makeVersion​(int major, int minor, int patch)` |
    `static int` | `poll​(ZMQ.PollItem[] items, int count, long timeout)` | Poll on polling items until timeout
    `static int` | `poll​(ZMQ.PollItem[] items, long timeout)` | Poll on polling items until timeout
    `static void` | `proxy​(ZMQ.Socket frontend, ZMQ.Socket backend, ZMQ.Socket capture)` | Starts the built-in 0MQ proxy in the current application thread.
    `protected static int` | `version_full()` |
    `protected static int` | `version_major()` |
    `protected static int` | `version_minor()` |
    `protected static int` | `version_patch()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### NOBLOCK

          public static final int NOBLOCK

      Socket flag to indicate a nonblocking send or recv mode.
      See Also:
        Constant Field Values

    - #### DONTWAIT

          public static final int DONTWAIT

      See Also:
        Constant Field Values

    - #### SNDMORE

          public static final int SNDMORE

      Socket flag to indicate that more message parts are coming.
      See Also:
        Constant Field Values

    - #### PAIR

          public static final int PAIR

      Flag to specify a exclusive pair of items.
      See Also:
        Constant Field Values

    - #### PUB

          public static final int PUB

      Flag to specify a PUB socket, receiving side must be a SUB or XSUB.
      See Also:
        Constant Field Values

    - #### SUB

          public static final int SUB

      Flag to specify the receiving part of the PUB or XPUB socket.
      See Also:
        Constant Field Values

    - #### REQ

          public static final int REQ

      Flag to specify a REQ socket, receiving side must be a REP.
      See Also:
        Constant Field Values

    - #### REP

          public static final int REP

      Flag to specify the receiving part of a REQ socket.
      See Also:
        Constant Field Values

    - #### DEALER

          public static final int DEALER

      Flag to specify a DEALER socket (aka XREQ). DEALER is really a combined ventilator / sink that does load-balancing on output and fair-queuing on input with no other semantics. It is the only socket type that lets you shuffle messages out to N nodes and shuffle the replies back, in a raw bidirectional asynch pattern.
      See Also:
        Constant Field Values

    - #### XREQ

          public static final int XREQ

      Deprecated.
      As of release 3.0 of zeromq, replaced by `DEALER`
      Old alias for DEALER flag. Flag to specify a XREQ socket, receiving side must be a XREP.
      See Also:
        Constant Field Values

    - #### ROUTER

          public static final int ROUTER

      Flag to specify ROUTER socket (aka XREP). ROUTER is the socket that creates and consumes request-reply routing envelopes. It is the only socket type that lets you route messages to specific connections if you know their identities.
      See Also:
        Constant Field Values

    - #### XREP

          public static final int XREP

      Deprecated.
      As of release 3.0 of zeromq, replaced by `ROUTER`
      Old alias for ROUTER flag. Flag to specify the receiving part of a XREQ socket.
      See Also:
        Constant Field Values

    - #### PULL

          public static final int PULL

      Flag to specify the receiving part of a PUSH socket.
      See Also:
        Constant Field Values

    - #### PUSH

          public static final int PUSH

      Flag to specify a PUSH socket, receiving side must be a PULL.
      See Also:
        Constant Field Values

    - #### XPUB

          public static final int XPUB

      Flag to specify a XPUB socket, receiving side must be a SUB or XSUB. Subscriptions can be received as a message. Subscriptions start with a '1' byte. Unsubscriptions start with a '0' byte.
      See Also:
        Constant Field Values

    - #### XSUB

          public static final int XSUB

      Flag to specify the receiving part of the PUB or XPUB socket. Allows
      See Also:
        Constant Field Values

    - #### STREAMER

          public static final int STREAMER

      Flag to specify a STREAMER device.
      See Also:
        Constant Field Values

    - #### FORWARDER

          public static final int FORWARDER

      Flag to specify a FORWARDER device.
      See Also:
        Constant Field Values

    - #### QUEUE

          public static final int QUEUE

      Flag to specify a QUEUE device.
      See Also:
        Constant Field Values

    - #### UPSTREAM

          @Deprecated
          public static final int UPSTREAM

      Deprecated.
      See Also:
        `PULL`, Constant Field Values

    - #### DOWNSTREAM

          @Deprecated
          public static final int DOWNSTREAM

      Deprecated.
      See Also:
        `PUSH`, Constant Field Values

    - #### EVENT_CONNECTED

          public static final int EVENT_CONNECTED

      EVENT_CONNECTED: connection established. The EVENT_CONNECTED event triggers when a connection has been established to a remote peer. This can happen either synchronous or asynchronous. Value is the FD of the newly connected socket.
      See Also:
        Constant Field Values

    - #### EVENT_CONNECT_DELAYED

          public static final int EVENT_CONNECT_DELAYED

      EVENT_CONNECT_DELAYED: synchronous connect failed, it's being polled. The EVENT_CONNECT_DELAYED event triggers when an immediate connection attempt is delayed and its completion is being polled for. Value has no meaning.
      See Also:
        Constant Field Values

    - #### EVENT_CONNECT_RETRIED

          public static final int EVENT_CONNECT_RETRIED

      EVENT_CONNECT_RETRIED: asynchronous connect / reconnection attempt. The EVENT_CONNECT_RETRIED event triggers when a connection attempt is being handled by reconnect timer. The reconnect interval's recomputed for each attempt. Value is the reconnect interval.
      See Also:
        Constant Field Values

    - #### EVENT_LISTENING

          public static final int EVENT_LISTENING

      EVENT_LISTENING: socket bound to an address, ready to accept connections. The EVENT_LISTENING event triggers when a socket's successfully bound to a an interface. Value is the FD of the newly bound socket.
      See Also:
        Constant Field Values

    - #### EVENT_BIND_FAILED

          public static final int EVENT_BIND_FAILED

      EVENT_BIND_FAILED: socket could not bind to an address. The EVENT_BIND_FAILED event triggers when a socket could not bind to a given interface. Value is the errno generated by the bind call.
      See Also:
        Constant Field Values

    - #### EVENT_ACCEPTED

          public static final int EVENT_ACCEPTED

      EVENT_ACCEPTED: connection accepted to bound interface. The EVENT_ACCEPTED event triggers when a connection from a remote peer has been established with a socket's listen address. Value is the FD of the accepted socket.
      See Also:
        Constant Field Values

    - #### EVENT_ACCEPT_FAILED

          public static final int EVENT_ACCEPT_FAILED

      EVENT_ACCEPT_FAILED: could not accept client connection. The EVENT_ACCEPT_FAILED event triggers when a connection attempt to a socket's bound address fails. Value is the errno generated by accept.
      See Also:
        Constant Field Values

    - #### EVENT_CLOSED

          public static final int EVENT_CLOSED

      EVENT_CLOSED: connection closed. The EVENT_CLOSED event triggers when a connection's underlying descriptor has been closed. Value is the former FD of the for the closed socket. FD has been closed already!
      See Also:
        Constant Field Values

    - #### EVENT_CLOSE_FAILED

          public static final int EVENT_CLOSE_FAILED

      EVENT_CLOSE_FAILED: connection couldn't be closed. The EVENT_CLOSE_FAILED event triggers when a descriptor could not be released back to the OS. Implementation note: ONLY FOR IPC SOCKETS. Value is the errno generated by unlink.
      See Also:
        Constant Field Values

    - #### EVENT_DISCONNECTED

          public static final int EVENT_DISCONNECTED

      EVENT_DISCONNECTED: broken session. The EVENT_DISCONNECTED event triggers when the stream engine (tcp and ipc specific) detects a corrupted / broken session. Value is the FD of the socket.
      See Also:
        Constant Field Values

    - #### EVENT_MONITOR_STOPPED

          public static final int EVENT_MONITOR_STOPPED

      EVENT_MONITOR_STOPPED: monitor has been stopped. The EVENT_MONITOR_STOPPED event triggers when the monitor for a socket is stopped.
      See Also:
        Constant Field Values

    - #### EVENT_ALL

          public static final int EVENT_ALL

      EVENT_ALL: all events known by the java binding. The EVENT_ALL constant can be used to set up a monitor for all events known by the java binding. One could add more flags
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ZMQ

          public ZMQ()

  - ### Method Detail

    - #### getMajorVersion

          public static int getMajorVersion()

      Returns:
        Major version number of the ZMQ library.

    - #### getMinorVersion

          public static int getMinorVersion()

      Returns:
        Major version number of the ZMQ library.

    - #### getPatchVersion

          public static int getPatchVersion()

      Returns:
        Major version number of the ZMQ library.

    - #### getFullVersion

          public static int getFullVersion()

      Returns:
        Full version number of the ZMQ library used for comparing versions.

    - #### makeVersion

          public static int makeVersion​(int major,
                                        int minor,
                                        int patch)

      Parameters:
        `major` - Version major component.
        `minor` - Version minor component.
        `patch` - Version patch component.
      Returns:
        Comparible single int version number.

    - #### getVersionString

          public static String getVersionString()

      Returns:
        String version number in the form major.minor.patch.

    - #### proxy

          public static void proxy​(ZMQ.Socket frontend,
                                   ZMQ.Socket backend,
                                   ZMQ.Socket capture)

      Starts the built-in 0MQ proxy in the current application thread. The proxy connects a frontend socket to a backend socket. Conceptually, data flows from frontend to backend. Depending on the socket types, replies may flow in the opposite direction. The direction is conceptual only; the proxy is fully symmetric and there is no technical difference between frontend and backend. Before calling ZMQ.proxy() you must set any socket options, and connect or bind both frontend and backend sockets. The two conventional proxy models are: ZMQ.proxy() runs in the current thread and returns only if/when the current context is closed.
      Parameters:
        `frontend` - ZMQ.Socket
        `backend` - ZMQ.Socket
        `capture` - If the capture socket is not NULL, the proxy shall send all messages, received on both frontend and backend, to the capture socket. The capture socket should be a ZMQ_PUB, ZMQ_DEALER, ZMQ_PUSH, or ZMQ_PAIR socket.
      Since:
        3.2.2

    - #### poll

          public static int poll​(ZMQ.PollItem[] items,
                                 long timeout)

      Poll on polling items until timeout
      Parameters:
        `items` - polling items
        `timeout` - timeout in millisecond
      Returns:
        number of events

    - #### poll

          public static int poll​(ZMQ.PollItem[] items,
                                 int count,
                                 long timeout)

      Poll on polling items until timeout
      Parameters:
        `items` - polling items
        `count` - active item count
        `timeout` - timeout in millisecond
      Returns:
        number of events

    - #### version_full

          protected static int version_full()

    - #### version_major

          protected static int version_major()

    - #### version_minor

          protected static int version_minor()

    - #### version_patch

          protected static int version_patch()

    - #### make_version

          protected static int make_version​(int major,
                                            int minor,
                                            int patch)

    - #### ENOTSUP

          protected static long ENOTSUP()

    - #### EPROTONOSUPPORT

          protected static long EPROTONOSUPPORT()

    - #### ENOBUFS

          protected static long ENOBUFS()

    - #### ENETDOWN

          protected static long ENETDOWN()

    - #### EADDRINUSE

          protected static long EADDRINUSE()

    - #### EADDRNOTAVAIL

          protected static long EADDRNOTAVAIL()

    - #### ECONNREFUSED

          protected static long ECONNREFUSED()

    - #### EINPROGRESS

          protected static long EINPROGRESS()

    - #### EHOSTUNREACH

          protected static long EHOSTUNREACH()

    - #### EMTHREAD

          protected static long EMTHREAD()

    - #### EFSM

          protected static long EFSM()

    - #### ENOCOMPATPROTO

          protected static long ENOCOMPATPROTO()

    - #### ETERM

          protected static long ETERM()

    - #### ENOTSOCK

          protected static long ENOTSOCK()

    - #### context

          public static ZMQ.Context context​(int ioThreads)

      Create a new Context.
      Parameters:
        `ioThreads` - Number of threads to use, usually 1 is sufficient for most use cases.
      Returns:
        the Context