6 Replies Latest reply on Apr 29, 2009 12:02 AM by Vlade Maksimovic

    JBoss 5.0.1, how to create new topic

    Vlade Maksimovic Newbie

      Hello...
      I need to create new topic in Jboss 5.0.1 from java applications. Did someone know how to do this.

      In Jboss 4.0.1sp1 I do this using next method in Java:

      private void createTopic(String topicName) throws NamingException, InstanceNotFoundException, MBeanException, ReflectionException, IOException {
       Properties props = new Properties();
       props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      
       InitialContext iniCtx = new InitialContext(props);
      
       try{
       iniCtx.lookup("topic/" + topicName + "");
       }catch (NameNotFoundException e) {
       ObjectName destinationManager = ObjectNameFactory.create("jboss.mq:service=DestinationManager");
       RMIAdaptor server = null;
       server = (RMIAdaptor) iniCtx.lookup("jmx/invoker/RMIAdaptor");
       server.invoke(destinationManager, "createTopic", new Object[] { topicName, "topic/" + topicName }, new String[] {
       String.class.getName(), String.class.getName() });
       }
       }
      
      


      I try to modificate previous code to work with Jboss 5.0.1GA, but I not success. Sorry on very bad English.