Esempio n. 1
0
 public void stop() {
   Log.write("Stopping service on port " + this.port);
   external.close();
   internal.close();
   context.term();
   Log.write("Stopped service on port " + this.port);
 }
Esempio n. 2
0
 public synchronized void start() {
   Log.write("Starting service on " + this.port);
   this.context = ZMQ.context(1);
   this.internal = context.socket(ZMQ.DEALER);
   this.internal.bind(getInternalAddress());
   this.external = context.socket(ZMQ.ROUTER);
   this.external.bind(getExternalAddress());
   startWorkers();
   try {
     ZMQ.proxy(external, internal, null);
   } catch (ZError.IOException ex) {
     Throwable cause = ex.getCause();
     if (cause instanceof ClosedChannelException) {
       stop();
     } else {
       throw ex;
     }
   }
 }