Package com.sun.messaging.jmq.io

Examples of com.sun.messaging.jmq.io.Packet


    private void sendReply(IMQConnection con, Packet cmd_msg,
        int replyType, int status, String errMsg) {

        // Send reply
  Packet reply = new Packet(con.useDirectBuffers());
  reply.setPacketType(PacketType.OBJECT_MESSAGE);

  setProperties(reply, replyType, status, errMsg);

  parent.sendReply(con, cmd_msg, reply);
View Full Code Here


            return true;
        }
    }

    private void sendReply(int status, String emsg, IMQConnection con, Packet cmd_msg) {
      Packet reply = new Packet(con.useDirectBuffers());
      reply.setPacketType(PacketType.OBJECT_MESSAGE);

      setProperties(reply, MessageType.CHANGE_CLUSTER_MASTER_BROKER_REPLY, status, emsg);
        parent.sendReply(con, cmd_msg, reply);
    }
View Full Code Here

        return super.handle(con, msg);
      }
    }
    // send the reply (if necessary)
    if (msg.getSendAcknowledge()) {
      Packet pkt = new Packet(con.useDirectBuffers());
      pkt.setPacketType(PacketType.SEND_REPLY);
      pkt.setConsumerID(msg.getConsumerID());
      Hashtable hash = new Hashtable();
      hash.put("JMQStatus", new Integer(Status.OK));
      pkt.setProperties(hash);
      con.sendControlMessage(pkt);
    }
   
    Producer pausedProducer = checkFlow(msg, con)
    if (pausedProducer!=null){
      DestinationUID duid = DestinationUID.getUID(msg.getDestination(),
                msg.getIsQueue());
      Destination d = Destination.findDestination(duid);
      pauseProducer(d, duid, pausedProducer, con);
    }

    // Administrative message. Process it.
    // Get message type property

    // Get AdminCmdHandler for this message type
    int t = msgType.intValue();
    AdminCmdHandler ach = null;

    /*
     * If the connection is authenticated using admin key authentication then it is considered "restricted" and can
     * only perform minimal operations. Anything else is forbidden.
     */
    if (con.getAccessController().isRestrictedAdmin() && t != MessageType.SHUTDOWN && t != MessageType.HELLO
        && t != MessageType.RESTART) {

      logger.log(Logger.WARNING, BrokerResources.W_FORBIDDEN_ADMIN_OP, MessageType.getString(t));

      Packet reply = new Packet(con.useDirectBuffers());
      reply.setPacketType(PacketType.OBJECT_MESSAGE);

      // By convention reply message is the message type + 1
      AdminCmdHandler.setProperties(reply, t + 1, Status.FORBIDDEN, null);

      sendReply(con, msg, reply);

      return true; // done
    }

    // if we arent shutdown .. track our handler cnt
    if (t != MessageType.SHUTDOWN)
      incrementActiveHandlers();

    try {
      if (BrokerStateHandler.shuttingDown) {

        String message = Globals.getBrokerResources().getKString(BrokerResources.I_ADMIN_BKR_SHUTTINGDOWN,
            MessageType.getString(t));

        logger.log(Logger.WARNING, message);

        Packet reply = new Packet(con.useDirectBuffers());
        reply.setPacketType(PacketType.OBJECT_MESSAGE);

        // By convention reply message is the message type + 1
        AdminCmdHandler.setProperties(reply, t + 1, Status.UNAVAILABLE, message);

        sendReply(con, msg, reply);

        return true; // done
      }
      if (!Broker.getBroker().startupComplete) {
        String message = Globals.getBrokerResources().getKString(BrokerResources.I_ADMIN_BKR_NOT_READY,
            MessageType.getString(t));

        logger.log(Logger.WARNING, message);

        Packet reply = new Packet(con.useDirectBuffers());
        reply.setPacketType(PacketType.OBJECT_MESSAGE);
        // By convention reply message is the message type + 1
        AdminCmdHandler.setProperties(reply, t + 1, Status.UNAVAILABLE, message);

        sendReply(con, msg, reply);

        return true; // done
      }

      try {
        ach = handlers[t];
      } catch (IndexOutOfBoundsException e) {
        logger.log(Logger.ERROR, BrokerResources.E_INTERNAL_BROKER_ERROR, "Bad " + MessageType.JMQ_MESSAGE_TYPE
            + ": " + t);
        return true;
      }
      if (ach == null) {
        logger.log(Logger.ERROR, BrokerResources.E_INTERNAL_BROKER_ERROR,
            "No administration handler found for message type " + msgType + ". Ignoring.");
        return true;
      } else {
        // Call command handler to handle message
        try {
          return ach.handle(con, msg, props);
        } catch (Exception e) {// Excepion before sendReply
          int estatus = Status.ERROR;
          String emsg = e.getMessage();
          if (e instanceof BrokerException) {
            estatus = ((BrokerException) e).getStatusCode();
          } else {
            emsg = Globals.getBrokerResources().getKString(BrokerResources.X_INTERNAL_EXCEPTION,
                e.toString());
          }
          logger.logStack(Logger.ERROR, emsg, e);
          Packet reply = new Packet(con.useDirectBuffers());
          reply.setPacketType(PacketType.OBJECT_MESSAGE);
          AdminCmdHandler.setProperties(reply, t + 1, estatus, emsg);
          sendReply(con, msg, reply);
          return true; // done
        }
      }
View Full Code Here

    // is this a restart?
    shouldRestart =  (restart == null ? false : restart.booleanValue());
    if (shouldRestart) noFailover=Boolean.TRUE;

  // Prepare reply
  Packet reply = new Packet(con.useDirectBuffers());
  reply.setPacketType(PacketType.OBJECT_MESSAGE);
 
  // not allowed to shutdown an in-process broker that has direct connections
    if (Broker.isInProcess() && !shouldRestart && hasDirectConnections()) {
      //TODO COrrect this message
      String error = rb.getString(BrokerResources.E_CANNOT_SHUTDOWN_IN_PROCESS);
View Full Code Here

               v.add(dd);
           }
       }

       // Send reply
       Packet reply = new Packet(con.useDirectBuffers());
       reply.setPacketType(PacketType.OBJECT_MESSAGE);
  
       setProperties(reply, MessageType.GET_DESTINATIONS_REPLY,
           status, errMsg);
  
       setBodyObject(reply, v);
View Full Code Here

                }
            }
        }

  // Send reply
  Packet reply = new Packet(con.useDirectBuffers());
  reply.setPacketType(PacketType.OBJECT_MESSAGE);

  setProperties(reply, MessageType.DESTROY_CONNECTION_REPLY,
    status, errMsg);

  parent.sendReply(con, cmd_msg, reply);
View Full Code Here

                 cmd_props);
        }
  String destination = (String)cmd_props.get(MessageType.JMQ_DESTINATION);

  // Send reply
  Packet reply = new Packet(con.useDirectBuffers());
  reply.setPacketType(PacketType.OBJECT_MESSAGE);
        int status = Status.OK;

        Vector v = null;
        String err = null;
        try {
View Full Code Here

        Integer length = (Integer)cmd_props.get("length");

        // If length == -1 it means get to end of file

  // Send reply
  Packet reply = new Packet(con.useDirectBuffers());
  reply.setPacketType(PacketType.BYTES_MESSAGE);

  setProperties(reply, MessageType.VIEW_LOG_REPLY, Status.NOT_IMPLEMENTED,
            null);

  parent.sendReply(con, cmd_msg, reply);
View Full Code Here

          v = csm.getConnectorInfo();
      }
  }

  // Send reply
  Packet reply = new Packet(con.useDirectBuffers());
  reply.setPacketType(PacketType.OBJECT_MESSAGE);

  setProperties(reply, MessageType.GET_JMX_REPLY,
    status, errMsg);

  setBodyObject(reply, v);
View Full Code Here

  if ( DEBUG ) {
            logger.log(Logger.DEBUG, this.getClass().getName() + ": " +
                "Creating destination: " + cmd_props + ": " + info.toString());
        }

  Packet reply = new Packet(con.useDirectBuffers());
  reply.setPacketType(PacketType.OBJECT_MESSAGE);

        int status = Status.OK;
        String errMsg = null;

        // Default attributes of the destination
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.io.Packet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.