1 Reply Latest reply on Aug 6, 2003 3:53 AM by huzzi

    Creating a Topic on the server from a JMS client?

    red_one

      How would I go about creating a Topic on the JBoss server from the JMS client (possibly using a JMS message?)

        • 1. Re: Creating a Topic on the server from a JMS client?
          huzzi

          create a MDB receiving the Topic name you wants to create and call from within the onMessage method:



          try {
          ArrayList srvs = MBeanServerFactory.findMBeanServer(null);
          Iterator iter = srvs.iterator();
          while (iter.hasNext()) {
          MBeanServer srv = (MBeanServer) iter.next();
          String domain = srv.getDefaultDomain();
          System.out.println(domain);
          if (domain.equals("jboss")) {
          mbeanSrv = srv;
          break;
          }
          }

          ObjectName name = new ObjectName("jboss.mq:service=DestinationManager");
          MBeanInfo info = mbeanSrv.getMBeanInfo(name);
          System.out.println("Conversion Class: " + info.getClassName());
          String opName = "createTopic";
          String sig[] = {
          "java.lang.String","java.lang.String"};
          Object opArgs[] = {
          ->your Topicname<-,->your jndi Topicname<-};
          Object result = mbeanSrv.invoke(name, opName, opArgs, sig);
          }

          catch (Exception ex) {
          ex.printStackTrace();
          }


          bye
          moritz