Search in sources :

Example 16 with DestinationInfo

use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.

the class UpdateDestinationHandler method handle.

/**
 * Handle the incomming administration message.
 *
 * @param con The Connection the message came in on.
 * @param cmd_msg The administration message
 * @param cmd_props The properties from the administration message
 */
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
    if (DEBUG) {
        logger.log(Logger.DEBUG, this.getClass().getName() + ": " + cmd_props);
    }
    // String destination = (String)cmd_props.get(MessageType.JMQ_DESTINATION);
    DestinationInfo info = (DestinationInfo) getBodyObject(cmd_msg);
    int status = Status.OK;
    String errMsg = null;
    HAMonitorService hamonitor = Globals.getHAMonitorService();
    if (hamonitor != null && hamonitor.inTakeover()) {
        status = Status.ERROR;
        errMsg = rb.getString(rb.E_CANNOT_PROCEED_TAKEOVER_IN_PROCESS);
        logger.log(Logger.ERROR, this.getClass().getName() + ": " + errMsg);
    } else {
        try {
            Destination[] ds = DL.getDestination(null, info.name, DestType.isQueue(info.type));
            // PART
            Destination d = ds[0];
            if (d == null) {
                errMsg = rb.getString(rb.X_DESTINATION_NOT_FOUND, info.name);
                status = Status.NOT_FOUND;
            } else {
                if (info.isModified(info.MAX_MESSAGES)) {
                    int maxMessages = info.maxMessages;
                    d.setCapacity(maxMessages);
                }
                if (info.isModified(info.MAX_MESSAGE_SIZE)) {
                    SizeString maxSize = new SizeString();
                    maxSize.setBytes(info.maxMessageSize);
                    d.setMaxByteSize(maxSize);
                }
                if (info.isModified(info.MAX_MESSAGE_BYTES)) {
                    SizeString maxBytes = new SizeString();
                    maxBytes.setBytes(info.maxMessageBytes);
                    d.setByteCapacity(maxBytes);
                }
                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_FAILOVER_CONSUMERS)) {
                    // PART
                    int maxcons = info.maxFailoverConsumers;
                    d.setMaxFailoverConsumers(maxcons);
                }
                if (info.isModified(info.MAX_PRODUCERS)) {
                    int maxproducers = info.maxProducers;
                    d.setMaxProducers(maxproducers);
                }
                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);
                }
                if (info.isModified(info.VALIDATE_XML_SCHEMA_ENABLED)) {
                    d.setValidateXMLSchemaEnabled(info.validateXMLSchemaEnabled);
                }
                if (info.isModified(info.XML_SCHEMA_URI_LIST)) {
                    d.setXMLSchemaUriList(info.XMLSchemaUriList);
                }
                if (info.isModified(info.RELOAD_XML_SCHEMA_ON_FAILURE)) {
                    d.setReloadXMLSchemaOnFailure(info.reloadXMLSchemaOnFailure);
                }
                d.update();
            }
        } catch (Exception ex) {
            errMsg = getMessageFromException(ex);
            status = Status.ERROR;
        }
    }
    // Send reply
    Packet reply = new Packet(con.useDirectBuffers());
    reply.setPacketType(PacketType.OBJECT_MESSAGE);
    setProperties(reply, MessageType.UPDATE_DESTINATION_REPLY, status, errMsg);
    parent.sendReply(con, cmd_msg, reply);
    return true;
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) SizeString(com.sun.messaging.jmq.util.SizeString) DestinationInfo(com.sun.messaging.jmq.util.admin.DestinationInfo) SizeString(com.sun.messaging.jmq.util.SizeString) HAMonitorService(com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService)

Example 17 with DestinationInfo

use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.

the class GetDestinationsHandler method handle.

/**
 * Handle the incomming administration message.
 *
 * @param con The Connection the message came in on.
 * @param cmd_msg The administration message
 * @param cmd_props The properties from the administration message
 */
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
    if (DEBUG) {
        logger.log(Logger.INFO, "GetDestiantionsHandler: " + cmd_props);
    }
    Vector v = new Vector();
    int status = Status.OK;
    String errMsg = null;
    String destination = (String) cmd_props.get(MessageType.JMQ_DESTINATION);
    Integer destType = (Integer) cmd_props.get(MessageType.JMQ_DEST_TYPE);
    Boolean val = (Boolean) cmd_props.get(MessageType.JMQ_SHOW_PARTITION);
    boolean showpartition = (val != null && val.booleanValue());
    val = (Boolean) cmd_props.get(MessageType.JMQ_LOAD_DESTINATION);
    boolean load = (val != null && val.booleanValue());
    assert destination == null || destType != null;
    if (destination != null) {
        try {
            Destination[] ds = DL.getDestination(null, destination, DestType.isQueue(destType.intValue()));
            Destination d = null;
            DestinationInfo dinfo = null;
            for (int i = 0; i < ds.length; i++) {
                d = ds[i];
                if (d != null) {
                    if (DEBUG) {
                        d.debug();
                    }
                    if (load) {
                        d.load();
                    }
                    dinfo = getDestinationInfo(d, dinfo, showpartition);
                    if (showpartition) {
                        v.add(dinfo);
                    }
                }
            }
            if (dinfo == null) {
                throw new BrokerException(rb.getString(rb.X_DESTINATION_NOT_FOUND, destination), Status.NOT_FOUND);
            }
            if (!showpartition) {
                v.add(dinfo);
            }
        } catch (Exception ex) {
            status = Status.ERROR;
            errMsg = ex.getMessage();
            if (ex instanceof BrokerException) {
                status = ((BrokerException) ex).getStatusCode();
            }
            logger.logStack(Logger.ERROR, errMsg, ex);
        }
    } else {
        try {
            LinkedHashMap<DestinationUID, DestinationInfo> map = new LinkedHashMap<>();
            Iterator[] itrs = DL.getAllDestinations(null);
            int cnt = itrs.length;
            DestinationInfo dinfo = null;
            DestinationUID duid = null;
            Destination d = null;
            for (int i = 0; i < cnt; i++) {
                Iterator itr = itrs[i];
                while (itr.hasNext()) {
                    d = (Destination) itr.next();
                    if (load) {
                        d.load();
                    }
                    duid = d.getDestinationUID();
                    dinfo = map.get(d.getDestinationUID());
                    dinfo = getDestinationInfo(d, dinfo, showpartition);
                    map.put(duid, dinfo);
                    if (showpartition) {
                        v.add(dinfo);
                    }
                }
            }
            if (!showpartition) {
                Iterator<DestinationInfo> itr = map.values().iterator();
                while (itr.hasNext()) {
                    v.add(itr.next());
                }
            }
        } catch (Exception ex) {
            status = Status.ERROR;
            errMsg = ex.getMessage();
            if (ex instanceof BrokerException) {
                status = ((BrokerException) ex).getStatusCode();
            }
            logger.logStack(Logger.ERROR, errMsg, ex);
        }
    }
    // Send reply
    Packet reply = new Packet(con.useDirectBuffers());
    reply.setPacketType(PacketType.OBJECT_MESSAGE);
    setProperties(reply, MessageType.GET_DESTINATIONS_REPLY, status, errMsg);
    setBodyObject(reply, v);
    parent.sendReply(con, cmd_msg, reply);
    return true;
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) DestinationInfo(com.sun.messaging.jmq.util.admin.DestinationInfo) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) SizeString(com.sun.messaging.jmq.util.SizeString) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) LinkedHashMap(java.util.LinkedHashMap) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) Iterator(java.util.Iterator) Vector(java.util.Vector)

Example 18 with DestinationInfo

use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.

the class GetDestinationsHandler method getDestinationInfo.

private static DestinationInfo getDestinationInfo(Destination d, DestinationInfo dinfo, boolean showpartition) {
    DestinationInfo di = dinfo;
    if (di == null || showpartition) {
        di = new DestinationInfo();
    }
    d.getSizeInfo(di);
    if (dinfo == null || showpartition) {
        di.nConsumers = d.getConsumerCount();
        di.nfConsumers = d.getFailoverConsumerCount();
        di.naConsumers = d.getActiveConsumerCount();
    }
    di.nProducers += d.getProducerCount();
    if (dinfo == null || showpartition) {
        di.autocreated = (d.isAutoCreated() || d.isInternal() || d.isDMQ() || d.isAdmin());
    }
    if (dinfo == null || showpartition) {
        di.destState = d.getState();
    }
    if (d.isAdmin() || !showpartition) {
        di.name = d.getDestinationName();
    } else {
        PartitionedStore pstore = d.getPartitionedStore();
        di.name = d.getDestinationName() + "[" + pstore.getPartitionID() + (pstore.isPrimaryPartition() ? "*]" : "]");
    }
    if (dinfo == null || showpartition) {
        di.type = d.getType() & ~(DestType.DEST_INTERNAL | DestType.DEST_AUTO | DestType.DEST_ADMIN);
        di.fulltype = d.getType();
    }
    di.maxMessages += d.getCapacity();
    if (di.maxMessages < 0) {
        di.maxMessages = 0;
    }
    SizeString bc = d.getByteCapacity();
    di.maxMessageBytes += (bc == null ? 0 : bc.getBytes());
    if (di.maxMessageBytes < 0) {
        di.maxMessageBytes = 0;
    }
    bc = d.getMaxByteSize();
    di.maxMessageSize += (bc == null ? 0 : bc.getBytes());
    if (di.maxMessageSize < 0) {
        di.maxMessageSize = 0;
    }
    if (dinfo == null || showpartition) {
        di.destScope = d.getScope();
        di.destLimitBehavior = d.getLimitBehavior();
        di.maxPrefetch = d.getMaxPrefetch();
        di.destCDP = d.getClusterDeliveryPolicy();
        di.maxActiveConsumers = d.getMaxActiveConsumers();
        di.maxFailoverConsumers = d.getMaxFailoverConsumers();
        di.maxProducers = d.getMaxProducers();
        di.maxNumSharedConsumers = d.getMaxNumSharedConsumers();
        di.sharedConsumerFlowLimit = d.getSharedConsumerFlowLimit();
        di.useDMQ = d.getUseDMQ();
        di.validateXMLSchemaEnabled = d.validateXMLSchemaEnabled();
        di.XMLSchemaUriList = d.getXMLSchemaUriList();
        di.reloadXMLSchemaOnFailure = d.reloadXMLSchemaOnFailure();
    }
    if (!d.isQueue()) {
        Hashtable<String, Integer> h = new Hashtable<>();
        if (dinfo == null || showpartition) {
            if (di.nConsumers > 0) {
                Iterator consumers = d.getConsumers();
                while (consumers.hasNext()) {
                    Consumer oneCon = (Consumer) consumers.next();
                    if (oneCon.isWildcard()) {
                        DestinationUID id = oneCon.getDestinationUID();
                        String wildcard = id.getName();
                        Integer count = h.get(wildcard), newCount;
                        if (count == null) {
                            newCount = Integer.valueOf(1);
                        } else {
                            newCount = Integer.valueOf(count.intValue() + 1);
                        }
                        h.put(wildcard, newCount);
                    }
                }
            }
            if (h.size() > 0) {
                di.consumerWildcards = h;
            }
        }
        h = di.producerWildcards;
        if (h == null) {
            h = new Hashtable<>();
        }
        if (di.nProducers > 0) {
            Iterator producers = d.getProducers();
            while (producers.hasNext()) {
                Producer oneProd = (Producer) producers.next();
                if (oneProd.isWildcard()) {
                    DestinationUID id = oneProd.getDestinationUID();
                    String wildcard = id.getName();
                    Integer count = h.get(wildcard), newCount;
                    if (count == null) {
                        newCount = Integer.valueOf(1);
                    } else {
                        newCount = Integer.valueOf(count.intValue() + 1);
                    }
                    h.put(wildcard, newCount);
                }
            }
        }
        if (h.size() > 0) {
            di.producerWildcards = h;
        }
    }
    return di;
}
Also used : SizeString(com.sun.messaging.jmq.util.SizeString) DestinationInfo(com.sun.messaging.jmq.util.admin.DestinationInfo) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) Consumer(com.sun.messaging.jmq.jmsserver.core.Consumer) Producer(com.sun.messaging.jmq.jmsserver.core.Producer) Hashtable(java.util.Hashtable) Iterator(java.util.Iterator) SizeString(com.sun.messaging.jmq.util.SizeString) PartitionedStore(com.sun.messaging.jmq.jmsserver.persist.api.PartitionedStore)

Example 19 with DestinationInfo

use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.

the class CmdRunner method runPurgeAll.

private int runPurgeAll(BrokerCmdProperties brokerCmdProps) {
    BrokerAdmin broker;
    String input = null;
    String yes, yesShort, no, noShort;
    int ret_code = 0;
    yes = ar.getString(ar.Q_RESPONSE_YES);
    yesShort = ar.getString(ar.Q_RESPONSE_YES_SHORT);
    no = ar.getString(ar.Q_RESPONSE_NO);
    noShort = ar.getString(ar.Q_RESPONSE_NO_SHORT);
    String commandArg = brokerCmdProps.getCommandArg();
    boolean force = brokerCmdProps.forceModeSet();
    broker = init();
    if (CMDARG_DESTINATION.equals(commandArg)) {
        if (broker == null) {
            Globals.stdErrPrintln("Purging all the destinations failed");
            return (1);
        }
        if (!force)
            broker = promptForAuthentication(broker);
        Globals.stdOutPrintln("Purging all the destinations");
        Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
        printBrokerInfo(broker);
        try {
            connectToBroker(broker);
        } catch (BrokerAdminException bae) {
            handleBrokerAdminException(bae);
            Globals.stdErrPrintln("Purging all the destinations failed");
            return (1);
        }
        if (!force) {
            input = CommonCmdRunnerUtil.getUserInput("Are you sure you want to purge all the destinations? (y/n)[n] ", noShort);
            Globals.stdOutPrintln("");
        }
        if (yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input) || force) {
            try {
                boolean dstsPurged = false;
                /*
                     * List all destinations
                     */
                broker.sendGetDestinationsMessage(null, -1);
                Vector dests = broker.receiveGetDestinationsReplyMessage();
                if (dests != null) {
                    Enumeration thisEnum = dests.elements();
                    while (thisEnum.hasMoreElements()) {
                        DestinationInfo dInfo = (DestinationInfo) thisEnum.nextElement();
                        String destName;
                        int destTypeMask;
                        destName = dInfo.name;
                        destTypeMask = dInfo.type;
                        if (MessageType.JMQ_ADMIN_DEST.equals(destName) || MessageType.JMQ_BRIDGE_ADMIN_DEST.equals(destName) || DestType.isInternal(dInfo.fulltype) || DestType.isTemporary(dInfo.type)) {
                            Globals.stdOutPrintln("Skipping destination: " + destName);
                            continue;
                        }
                        try {
                            broker.sendPurgeDestinationMessage(destName, destTypeMask);
                            broker.receivePurgeDestinationReplyMessage();
                            if (DestType.isQueue(destTypeMask)) {
                                Globals.stdOutPrintln("Successfully purged queue " + destName);
                            } else {
                                Globals.stdOutPrintln("Successfully purged topic " + destName);
                            }
                            dstsPurged = true;
                        } catch (BrokerAdminException purgeEx) {
                            handleBrokerAdminException(purgeEx);
                            if (DestType.isQueue(destTypeMask)) {
                                Globals.stdOutPrintln("Purging failed for queue " + destName);
                            } else {
                                Globals.stdOutPrintln("Purging failed for topic " + destName);
                            }
                            ret_code = 1;
                        }
                    }
                }
                if (!dstsPurged) {
                    Globals.stdOutPrintln("No destinations purged.");
                }
            } catch (BrokerAdminException bae) {
                handleBrokerAdminException(bae);
                Globals.stdErrPrintln("Purging all the destinations failed");
                return (1);
            }
        } else if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
            Globals.stdOutPrintln("The destinations were not purged.");
            return (0);
        } else {
            Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
            Globals.stdOutPrintln("");
            Globals.stdOutPrintln("The destinations were not purged.");
            return (1);
        }
    }
    broker.close();
    return (ret_code);
}
Also used : BrokerAdminException(com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException) BrokerAdmin(com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin) Enumeration(java.util.Enumeration) DestinationInfo(com.sun.messaging.jmq.util.admin.DestinationInfo) SizeString(com.sun.messaging.jmq.util.SizeString) Vector(java.util.Vector)

Example 20 with DestinationInfo

use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.

the class CmdRunner method runCreate.

private int runCreate(BrokerCmdProperties brokerCmdProps) {
    BrokerAdmin broker;
    DestinationInfo destInfo;
    String destName;
    int destTypeMask;
    Properties destAttrs;
    broker = init();
    if (broker == null) {
        Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_CREATE_DST_FAIL));
        return (1);
    }
    boolean force = brokerCmdProps.forceModeSet();
    if (!force)
        broker = promptForAuthentication(broker);
    destName = brokerCmdProps.getTargetName();
    destTypeMask = getDestTypeMask(brokerCmdProps);
    destAttrs = brokerCmdProps.getTargetAttrs();
    Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_CREATE_DST));
    BrokerCmdPrinter bcp = new BrokerCmdPrinter(2, 4);
    String[] row = new String[2];
    bcp.setSortNeeded(false);
    row[0] = ar.getString(ar.I_JMQCMD_DST_NAME);
    row[1] = destName;
    bcp.add(row);
    row[0] = ar.getString(ar.I_JMQCMD_DST_TYPE);
    row[1] = BrokerAdminUtil.getDestinationType(destTypeMask);
    bcp.add(row);
    /*
         * // Only print out the flavor type if the destination is a queue. if (DestType.isQueue(destTypeMask)) { row[0] =
         * ar.getString(ar.I_JMQCMD_DST_FLAVOR); row[1] = BrokerAdminUtil.getDestinationFlavor(destTypeMask); bcp.add(row); }
         */
    // Check for optional destination attributes.
    // Note that the same checking is done twice; once for printing
    // and once for creating the DestinationInfo object. It can
    // be combined, but this is cleaner.
    String prop = null;
    if ((prop = destAttrs.getProperty(PROP_NAME_OPTION_MAX_MESG)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_MSG_ALLOW);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_OPTION_MAX_MESG_BYTE)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_MSG_BYTES_ALLOW);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_OPTION_MAX_PER_MESG_SIZE)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_BYTES_PER_MSG_ALLOW);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_MAX_PRODUCERS)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_PRODUCERS);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_MAX_ACTIVE_CONSUMER_COUNT)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_ACTIVE_CONSUMER_COUNT);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_MAX_FAILOVER_CONSUMER_COUNT)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_FAILOVER_CONSUMER_COUNT);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_LIMIT_BEHAVIOUR)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_LIMIT_BEHAVIOUR);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_CONSUMER_FLOW_LIMIT)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_CONS_FLOW_LIMIT);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_IS_LOCAL_DEST)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_IS_LOCAL_DEST);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_LOCAL_DELIVERY_PREF)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_LOCAL_DELIVERY_PREF);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_USE_DMQ)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_USE_DMQ);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_VALIDATE_XML_SCHEMA_ENABLED)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_VALIDATE_XML_SCHEMA_ENABLED);
        row[1] = prop;
        bcp.add(row);
    }
    if ((prop = destAttrs.getProperty(PROP_NAME_XML_SCHEMA_URI_LIST)) != null) {
        row[0] = ar.getString(ar.I_JMQCMD_DST_XML_SCHEMA_URI_LIST);
        row[1] = prop;
        bcp.add(row);
    }
    bcp.println();
    Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
    printBrokerInfo(broker);
    try {
        SizeString ss;
        long byteValue;
        destInfo = new DestinationInfo();
        destInfo.setType(destTypeMask);
        destInfo.setName(destName);
        // Check for optional destination attributes
        if ((prop = destAttrs.getProperty(PROP_NAME_OPTION_MAX_MESG_BYTE)) != null) {
            try {
                ss = new SizeString(prop);
                byteValue = ss.getBytes();
                destInfo.setMaxMessageBytes(byteValue);
            } catch (NumberFormatException nfe) {
            /*
                     * Do nothing. We shouldn't ever get here since we do input validation prior to all this.
                     */
            }
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_OPTION_MAX_MESG)) != null) {
            destInfo.setMaxMessages(Integer.parseInt(prop));
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_OPTION_MAX_PER_MESG_SIZE)) != null) {
            try {
                ss = new SizeString(prop);
                byteValue = ss.getBytes();
                destInfo.setMaxMessageSize(byteValue);
            } catch (NumberFormatException nfe) {
            /*
                     * Do nothing. We shouldn't ever get here since we do input validation prior to all this.
                     */
            }
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_MAX_FAILOVER_CONSUMER_COUNT)) != null) {
            destInfo.setMaxFailoverConsumers(Integer.parseInt(prop));
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_MAX_ACTIVE_CONSUMER_COUNT)) != null) {
            destInfo.setMaxActiveConsumers(Integer.parseInt(prop));
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_IS_LOCAL_DEST)) != null) {
            destInfo.setScope(Boolean.parseBoolean(prop));
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_LIMIT_BEHAVIOUR)) != null) {
            destInfo.setLimitBehavior(getLimitBehavValue(prop));
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_LOCAL_DELIVERY_PREF)) != null) {
            destInfo.setClusterDeliveryPolicy(getClusterDeliveryPolicy(prop));
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_CONSUMER_FLOW_LIMIT)) != null) {
            destInfo.setPrefetch(Integer.parseInt(prop));
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_MAX_PRODUCERS)) != null) {
            destInfo.setMaxProducers(Integer.parseInt(prop));
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_USE_DMQ)) != null) {
            destInfo.setUseDMQ(Boolean.parseBoolean(prop));
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_VALIDATE_XML_SCHEMA_ENABLED)) != null) {
            destInfo.setValidateXMLSchemaEnabled(Boolean.parseBoolean(prop));
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_XML_SCHEMA_URI_LIST)) != null) {
            destInfo.setXMLSchemaUriList(prop);
        }
        if ((prop = destAttrs.getProperty(PROP_NAME_RELOAD_XML_SCHEMA_ON_FAILURE)) != null) {
            destInfo.setReloadXMLSchemaOnFailure(Boolean.parseBoolean(prop));
        }
        connectToBroker(broker);
        broker.sendCreateDestinationMessage(destInfo);
        broker.receiveCreateDestinationReplyMessage();
        Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_CREATE_DST_SUC));
    } catch (BrokerAdminException bae) {
        handleBrokerAdminException(bae);
        Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_CREATE_DST_FAIL));
        return (1);
    }
    broker.close();
    return (0);
}
Also used : SizeString(com.sun.messaging.jmq.util.SizeString) BrokerAdminException(com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException) BrokerAdmin(com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin) DestinationInfo(com.sun.messaging.jmq.util.admin.DestinationInfo) SizeString(com.sun.messaging.jmq.util.SizeString) Properties(java.util.Properties)

Aggregations

DestinationInfo (com.sun.messaging.jmq.util.admin.DestinationInfo)31 BrokerAdmin (com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin)14 SizeString (com.sun.messaging.jmq.util.SizeString)13 BrokerAdminException (com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException)12 Vector (java.util.Vector)11 Enumeration (java.util.Enumeration)10 ServiceInfo (com.sun.messaging.jmq.util.admin.ServiceInfo)4 Properties (java.util.Properties)4 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)3 DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)3 Hashtable (java.util.Hashtable)3 Iterator (java.util.Iterator)3 AdministeredObject (com.sun.messaging.AdministeredObject)2 HAMonitorService (com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService)2 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)2 ObjectMessage (jakarta.jms.ObjectMessage)2 BrokerAdminEvent (com.sun.messaging.jmq.admin.event.BrokerAdminEvent)1 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)1 Producer (com.sun.messaging.jmq.jmsserver.core.Producer)1 PartitionedStore (com.sun.messaging.jmq.jmsserver.persist.api.PartitionedStore)1