private boolean isHeartbeatMsg() { return sockets.pollin(1); }
public static Socket send(Socket socket, byte[] message, int flags) { socket.send(message, flags); return socket; }
@Override public List<String> call() throws Exception { try (ZMQ.Socket subscriber = context.socket(ZMQ.SUB)) { subscriber.connect(endpoint); subscriber.subscribe(new byte[0]); for (int messageNum = 0; messageNum < receiveCount && !Thread.currentThread().isInterrupted(); messageNum++) { // Use trim to remove the tailing '0' character messages.add(subscriber.recvStr(0).trim()); } } return messages; } }
private void closeSockets() { try { if (shellSocket != null) { shellSocket.close(); } if (controlSocket != null) { controlSocket.close(); } if (iopubSocket != null) { iopubSocket.close(); } if (stdinSocket != null) { stdinSocket.close(); } if (hearbeatSocket != null) { hearbeatSocket.close(); } context.close(); } catch (Exception e) { } }
@Override public void close() { socket.close(); }
public static Socket connect(Socket socket, String url) { socket.connect(url); return socket; }
public static Socket bind(Socket socket, String url) { socket.bind(url); return socket; }
public static Socket socket(Context context, int type) { return context.socket(type); }
public static byte[] recv(Socket socket, int flags) { return socket.recv(flags); }
public static Context context(int threads) { try { return ZMQ.context(threads); } catch (UnsatisfiedLinkError e) { LOG.error("context", e); } return null; }
public static Socket subscribe(Socket socket, byte[] topic) { socket.subscribe(topic); return socket; }
@Override public void term() { context.term(); }
public static Socket set_linger(Socket socket, long linger_ms) { socket.setLinger(linger_ms); return socket; }
public static Socket set_hwm(Socket socket, long hwm) { socket.setHWM(hwm); return socket; }
public static Socket unsubscribe(Socket socket, byte[] topic) { socket.unsubscribe(topic); return socket; }
private boolean isControlMsg() { return sockets.pollin(0); }
private boolean isShellMsg() { return sockets.pollin(2); }
private boolean isStdinMsg() { return sockets.pollin(3); }