예제 #1
0
 /**
  * 发送的消息格式: [000] [006] MDPC01 [004] echo [011] Hello world
  *
  * @param service
  * @param request
  */
 public void send(String service, ZMsg request) {
   assert (request == null);
   request.addFirst(service); // 在reqeust前面添加帧
   request.addFirst(MDP.C_CLIENT.newFrame());
   request.addFirst("");
   if (verbose) {
     log.format("I:send request to '%s' service.\n", service);
     request.dump(log.out());
   }
   request.send(client);
 }
예제 #2
0
 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();
 }