2 Replies Latest reply on Jun 25, 2011 2:58 AM by navnath

    Create new JMS resource [queue/topic] in runtime

    Alexander Lengson Newbie

      JBoss Messaging 1.4.1.GA on JBoss AS 5.0.1 GA does not allow creating new destinations in runtime when using pure JMS API (neither by client nor on server).
      Exception is thrown:

      javax.jms.JMSException: There is no administratively defined topic with name:newTopic


      Is it allowed to register new JMS resource other from temporary in runtime?


        • 1. Re: Create new JMS resource [queue/topic] in runtime
          Alexander Lengson Newbie

          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 Newbie

            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.