Refine search
/** * Stops ZeroMQ streamer. */ @Override public void close() throws Exception { isStarted = false; if (ctx != null) ctx.close(); if (zeroMqExSrv != null) { zeroMqExSrv.shutdown(); try { if (!zeroMqExSrv.awaitTermination(timeout, TimeUnit.MILLISECONDS)) log.warning("Timed out waiting for consumer threads to shut down, exiting uncleanly."); } catch (InterruptedException ignored) { zeroMqExSrv.shutdownNow(); log.error("Interrupted during shutdown, exiting uncleanly."); } } } }
@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; } }
@Override public void term() { context.term(); }
public static Socket socket(Context context, int type) { return context.socket(type); }
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) { } }
/** * Create a new Context. * * @param ioThreads Number of threads to use, usually 1 is sufficient for most use cases. * @return the Context */ public static Context context(int ioThreads) { return new Context(ioThreads); }
public void close() { term(); }
public boolean SendData(byte[] data) { ZMsg msg = new ZMsg(); msg.add(data); ZMQ.Socket sendSocket = context.socket(ZMQ.PUSH); sendSocket.setIdentity("shim".getBytes()); sendSocket.connect(CONTROL_ADDRESS); send(msg, sendSocket); sendSocket.close(); return true; }
/** * Create a new Context. * * @param ioThreads * Number of threads to use, usually 1 is sufficient for most use cases. * @return the Context */ public static Context context(int ioThreads) { return new Context(ioThreads); }