From JBoss Messaging Forum "Programmaticaly create queue"
- Get MBeanServer Connection
JMXServiceURL u = new JMXServiceURL( "service:jmx:rmi:///jndi/rmi://localhost:1090/jmxconnector"); JMXConnector c = JMXConnectorFactory.connect(u); beanServerConnection = c.getMBeanServerConnection();
- 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
- Undeploy a queue
beanServerConnection.invoke(objName, "undeployQueue", new Object[] { serviceName }, new String[] { "java.lang.String" });
- 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
Comments