Message Queue, v4.5.1 API Specification

Package com.sun.messaging.jms.management.server

Provides utility/convenience classes for writing JMX based clients to manage or monitor the MQ broker.

See: Description

Package com.sun.messaging.jms.management.server Description

Provides utility/convenience classes for writing JMX based clients to manage or monitor the MQ broker. The code example creates a destination on the broker and demonstrates how some of the classes in this package can be used for this.

import javax.management.*;
import javax.management.remote.*;
import com.sun.messaging.AdminConnectionFactory;
import com.sun.messaging.jms.management.server.*;

public class SimpleClient {
    public static void main(String[] args) {
        try  {
            AdminConnectionFactory acf;

            /*
             * Create admin connection factory and connect to JMX Connector
             * server using administrator username/password.
             * A JMX connector client object is obtained from this.
             */
            acf = new AdminConnectionFactory();
            JMXConnector jmxc = acf.createConnection();

            /*
             * Get MBeanServer interface.
             */
            MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

            /*
             * Create object name of destination config mgr MBean.
             */
            ObjectName objName
                = new ObjectName(MQObjectName.DESTINATION_CONFIG_MGR_MBEAN_NAME);

            /*
             * Create attributes for new destination:
             *  MaxTotalMsgBytes = 100 Mb
             *  UseDMQ = true
             */
            AttributeList attrList = new AttributeList();
            Attribute attr;
            attr = new Attribute(DestinationAttributes.MAX_TOTAL_MSG_BYTES,
                            new Long(100 * 1024 * 1024));
            attrList.add(attr);
            attr = new Attribute(DestinationAttributes.USE_DMQ,
                            Boolean.TRUE);
            attrList.add(attr);

            /*
             * Setup parameters for create operation and also
             * it's signature.
             */
            Object params[] = { DestinationType.QUEUE,
                        "TestQueue",
                        attrList
                };
            String signature[] = {
                        String.getClass().getName(),
                        String.getClass().getName(),
                        attrList.getClass().getName()
                };

            /*
             * Invoke operation to create destination.
             */
            mbsc.invoke(objName, DestinationOperations.CREATE, params, signature);

            jmxc.close();
        } catch (Exception e)  {
            e.printStackTrace();
        }
    }
}
Message Queue, v4.5.1 API Specification

Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.