[jboss-user] [JBoss Messaging] - Re: Create new JMS resource [queue/topic] in runtime
sanches
do-not-reply at jboss.com
Wed Aug 12 05:55:17 EDT 2009
I've learned the way to manage JMS destinations via JMX.
The code creating new JMS queue in runtime could look like:
| try {
| MBeanServer server = MBeanServerLocator.locate();
| Set<ObjectName> objnames = server.queryNames(null, null);
| for (ObjectName on: objnames) {
| System.out.print(on.getCanonicalName());
| }
| ObjectName on = new ObjectName("jboss.messaging:service=ServerPeer");
| MBeanInfo info = server.getMBeanInfo(on);
| MBeanOperationInfo[] ops = info.getOperations();
| MBeanParameterInfo[] signatures = null;
| String deployQueue = "deployQueue";
| for (MBeanOperationInfo op: ops) {
| if (deployQueue.equals(op.getName())) {
| signatures = op.getSignature();
| break;
| }
| }
| if (signatures == null) {
| throw new RuntimeException("ServerPeer JBoss MBean has been changed. No '" + deployQueue + "' operation exist anymore.");
|
| }
| String[] ssigs = new String[signatures.length];
| for (int i=0; i < signatures.length; i++) {
| ssigs = signatures.getType();
| }
|
| Object[] params = new Object[2];
| params[0] = new String("newQueue01");
| params[1] = new String("newQueue01");
| server.invoke(on, deployQueue, params, ssigs);
| } catch (Exception e) {
| e.printStackTrace();
| }
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4249176#4249176
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4249176
More information about the jboss-user
mailing list