-
1. Re: Create new JMS resource [queue/topic] in runtime
sanches Aug 12, 2009 5:55 AM (in response to sanches)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(); }
-
2. Re: Create new JMS resource [queue/topic] in runtime
navnath Jun 25, 2011 2:58 AM (in response to sanches)Hi Alexander,
I had try your solution but that not worked for me.
The Exception on line
MBeanInfo info = server.getMBeanInfo(on);
is
javax.management.InstanceNotFoundException: jboss.messaging:service=Queue is not registered.
I have changed line
ObjectName on = new ObjectName("jboss.messaging:service=ServerPeer");
to
ObjectName on = new ObjectName("jboss.messaging:service=Queue");
There are some Queue are already present on my server(JBoss).
Want to create new queue at runtime.
Is there any extra configurations are required to run above code?
Please replay any one, I have stuck since last 9 days to create JMS queue at run time.
Thanks in advance.