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
}
}