}
public static void createDestination(DestinationInfo info) throws BrokerException {
String errMsg = null;
int status = Status.OK;
BrokerResources rb = Globals.getBrokerResources();
Logger logger = Globals.getLogger();
// Default attributes of the destination
int type = DestType.DEST_TYPE_QUEUE | DestType.DEST_FLAVOR_SINGLE;
int maxMessages = -1;
SizeString maxMessageBytes = null;
SizeString maxMessageSize = null;
if (MemoryGlobals.MEM_DISALLOW_CREATE_DEST) {
status = Status.ERROR;
errMsg = rb.W_LOW_MEM_REJECT_DEST;
} else if (info.isModified(DestinationInfo.NAME)) {
if (info.isModified(DestinationInfo.TYPE)) {
type = info.type;
}
if (info.isModified(DestinationInfo.MAX_MESSAGES)) {
maxMessages = info.maxMessages;
}
if (info.isModified(DestinationInfo.MAX_MESSAGE_BYTES)) {
maxMessageBytes = new SizeString();
maxMessageBytes.setBytes(info.maxMessageBytes);
}
if (info.isModified(DestinationInfo.MAX_MESSAGE_SIZE)) {
maxMessageSize = new SizeString();
maxMessageSize.setBytes(info.maxMessageSize);
}
} else {
status = Status.ERROR;
errMsg = rb.X_NO_DEST_NAME_SET;
}
//
//XXX create destination
if (status == Status.OK) {
if (DestType.destNameIsInternal(info.name)) {
status = Status.ERROR;
errMsg = rb.getKString( rb.X_CANNOT_CREATE_INTERNAL_DEST,
info.name,
DestType.INTERNAL_DEST_PREFIX);
} else {
if (CreateDestinationHandler.isValidDestinationName(info.name)) {
try {
Destination.createDestination(info.name,
type);
} catch (Exception ex) {
status = Status.ERROR;
errMsg = rb.getString( rb.X_CREATE_DEST_EXCEPTION,
info.name, getMessageFromException(ex));
if (ex instanceof ConflictException)
logger.log(Logger.INFO, errMsg, ex);
else
logger.logStack(Logger.INFO, errMsg, ex);
}
} else {
status = Status.ERROR;
errMsg = rb.getKString( rb.X_DEST_NAME_INVALID,
info.name);
}
}
}
if (status == Status.OK) {
try {
Destination d = Destination.getDestination(info.name, DestType.isQueue(type));
d.setCapacity(maxMessages);
d.setByteCapacity(maxMessageBytes);
d.setMaxByteSize(maxMessageSize);
if (info.isModified(info.DEST_SCOPE)) {
int scope = info.destScope;
d.setScope(scope);
}
if (info.isModified(info.DEST_LIMIT)) {
int destlimit = info.destLimitBehavior;
d.setLimitBehavior(destlimit);
}
if (info.isModified(info.DEST_PREFETCH)) {
int prefetch = info.maxPrefetch;
d.setMaxPrefetch(prefetch);
}
if (info.isModified(info.DEST_CDP)) {
int clusterdeliverypolicy = info.destCDP;
d.setClusterDeliveryPolicy(clusterdeliverypolicy);
}
if (info.isModified(info.MAX_ACTIVE_CONSUMERS)) {
int maxcons = info.maxActiveConsumers;
d.setMaxActiveConsumers(maxcons);
}
if (info.isModified(info.MAX_PRODUCERS)) {
int maxp = info.maxProducers;
d.setMaxProducers(maxp);
}
if (info.isModified(info.MAX_FAILOVER_CONSUMERS)) {
int maxcons = info.maxFailoverConsumers;
d.setMaxFailoverConsumers(maxcons);
}
if (info.isModified(info.MAX_SHARED_CONSUMERS)) {
int maxsharedcons = info.maxNumSharedConsumers;
d.setMaxSharedConsumers(maxsharedcons);
}
if (info.isModified(info.SHARE_FLOW_LIMIT)) {
int sflowlimit = info.sharedConsumerFlowLimit;
d.setSharedFlowLimit(sflowlimit);
}
if (info.isModified(info.USE_DMQ)) {
boolean dmq = info.useDMQ;
d.setUseDMQ(dmq);
}
d.update();
/*
// audit logging for create destination
Globals.getAuditSession().destinationOperation(
con.getUserName(), con.remoteHostString(),
MQAuditSession.CREATE_DESTINATION,
d.isQueue()?MQAuditSession.QUEUE:MQAuditSession.TOPIC,
d.getDestinationName());
*/
} catch (Exception ex) {
// remove the destination
try {
DestinationUID duid = DestinationUID.getUID(
info.name, DestType.isQueue(type));
Destination.removeDestination(duid, false, ex.toString());
} catch (Exception ex1) {
// if we cant destroy .. its ok .. ignore the exception
}
status = Status.ERROR;
errMsg = rb.getString( rb.X_UPDATE_DEST_EXCEPTION,
info.name, getMessageFromException(ex));
logger.log(Logger.WARNING, errMsg, ex);
}