コード例 #1
0
 /**
  * Generates a multi-line string representation of an {@link IonMessage}
  *
  * @param title a title (description) for this message. This text will be at the beginning of the
  *     multi-line output string.
  * @param msg the {@link IonMessage} to represent as a string.
  * @return a multi-line string representation of the message
  */
 public static String printMessage(String title, IonMessage msg) {
   StringBuilder sb = new StringBuilder("\t\n" + title + "\n");
   sb.append("Headers: ").append("\n");
   java.util.HashMap<String, Object> headers =
       (java.util.HashMap<String, Object>) msg.getIonHeaders();
   for (String s : headers.keySet()) {
     sb.append("\t").append(s).append(" :: ").append(headers.get(s)).append("\n");
   }
   sb.append("CONTENT: ").append("\n");
   sb.append("\t").append(msg.getContent()).append("\n");
   return sb.toString();
 }
コード例 #2
0
      @Override
      public void messageReceived(ion.core.messaging.IonMessage msg) {
        /* Acknowledge receipt of the message*/
        //                log.debug("Ack Message");
        this.ackMessage(msg);

        log.debug(printMessage("**Control Message Received**", msg));

        String op = msg.getIonHeaders().get("op").toString();
        log.debug("OP: " + op);
        String repTo = msg.getIonHeaders().get("reply-to").toString();
        if (op.equalsIgnoreCase("op_shutdown")) {
          log.debug("Shutdown Request Received");
          //                    this.send(new MessagingName(repTo), "op_shutdown_ack", "Shutdown
          // initiated");
          clistener.controlEvent(new ControlEvent(this, ControlEventType.SHUTDOWN, msg));
        } else if (op.equalsIgnoreCase("op_update")) {
          log.debug("Update Request Received");
          clistener.controlEvent(new ControlEvent(this, ControlEventType.UPDATE, msg));
        }
      }