public void run() { LOGGER.info("DynamicUtil run()"); String result = "result from dynamic worker"; // getParsedPage(); ZMsg msg = new ZMsg(); msg.addFirst(result); // msg.addFirst(new byte[0]); msg.wrap(sendTo); msg.addFirst(MDP.W_REPLY.newFrame()); msg.addFirst(MDP.DYNAMIC_WORKER.newFrame()); msg.addFirst(new byte[0]); // 这就是dealer与req的不同之处,req在此处会自动加入一个空帧 LOGGER.info("I:sending reply to broker\n" + msg.toString()); System.out.println("I:sending reply to broker\n" + msg.toString()); // msg.dump(log.out()); msg.send(worker); msg.destroy(); }
/** * DynamicUtil constructor * * @param worker * @param msg */ public DynamicUtil(Socket worker, ZMsg msg) { LOGGER.info("DynamicUtil msg from broker: \n" + msg.toString()); this.worker = worker; assert (msg.size() >= 3); this.msg = msg; sendTo = msg.unwrap(); // msg.pop(); ZFrame m = msg.pop(); data = m.toString(); LOGGER.info("DynamicUtil from broker data:" + data); if (!msg.isEmpty()) { clickButton = msg.popString(); } }