Beispiel #1
0
 public void send() {
   Msg msg = this.mp.getMsg();
   try {
     msg.getOut().put("Simple request".getBytes("UTF-8"));
   } catch (UnsupportedEncodingException e) {
     // Just suppress the exception handling in this demo code
   }
   try {
     client.sendRequest(msg);
   } catch (IOException e) {
     // all exceptions thrown extend IOException
     LOG.error(e.toString());
   }
 }
Beispiel #2
0
    public void onResponse(Msg msg) {
      ++numberofRsps;

      if (numberofRsps % PRINT_COUNTER == 0) {
        // Read reply message String
        byte ch;
        StringBuffer buffer = new StringBuffer();
        while (msg.getIn().hasRemaining() && ((ch = msg.getIn().get()) > -1)) {
          buffer.append((char) ch);
        }
        LOG.info("Got message response " + numberofRsps + ": '" + buffer.toString() + "'");
      }

      msg.returnToParentPool();
      exitStatus = 0; // Success, we got our message response back
    }
Beispiel #3
0
 public void onMsgError(Msg msg, EventReason reason) {
   LOG.info("[ERROR] onMsgErrorCallback. reason=" + reason);
   if (reason == EventReason.MSG_FLUSHED) {
     LOG.info("[STATUS] getIsClosing() = " + this.client.client.getIsClosing());
   }
   msg.returnToParentPool();
   this.client.exitStatus = 1; // Failure on any kind of error
   System.exit(exitStatus);
 }