Version 1

    From JBoss Messaging Forum "Programmaticaly create queue"

     

    1. Get MBeanServer Connection
          
      JMXServiceURL u = new JMXServiceURL(
           "service:jmx:rmi:///jndi/rmi://localhost:1090/jmxconnector");
      JMXConnector c = JMXConnectorFactory.connect(u);     
      beanServerConnection = c.getMBeanServerConnection();

    2. Deploy a queue with servieName
      ObjectName objName = new ObjectName(
                          "jboss.messaging:service=ServerPeer");
      beanServerConnection.invoke(objName, "deployQueue",
                              new Object[] { serviceName, null },
                              new String[] { "java.lang.String",
                                             "java.lang.String" });
      

      more configuration about ServerPeer, such as attribute and operations could be founed at JBoss Messaging User Guide


    3. Undeploy a queue
      beanServerConnection.invoke(objName, "undeployQueue",
                              new Object[] { serviceName },
                              new String[] { "java.lang.String" });
      
      

    4. Customize security to queues which created using the MBean

      you should define a  element first, such as following example:

      <security>
          <role name="guest" read="true" write="true" create="true"/>
          <role name="publisher" read="true" write="true" create="false"/>
          <role name="durpublisher" read="true" write="true" create="true"/>
      </security>

      then use setAttribute:

      Element element = stringToElement(security);
      Attribute attr = new Attribute("SecurityConfig", element);
      ObjectName queueName = new ObjectName(
        "jboss.messaging.destination:service=Queue,name=" + serviceName);
      beanServerConnection.setAttribute(objName, attr);
      
      
      More configuration about destination could be founded at Configuration Destinations