4 Replies Latest reply on Dec 28, 2001 9:20 PM by Michael Lu

    creating multiple topics

    garyg Novice

      I'm not exactly sure how to publish mutltiple topics, so could someone give me a hand on the way I'm doing it. Note the last exception that is being thrown currently.

      ...
      try {
      ctx = new InitialContext();
      }
      catch (NamingException ne) {
      log.warn(InitBuildBean.class, "publishBuild: Could not create "
      + "JNDI context");
      }

      try {
      // lookup the connection factory and topic
      // todo: if not exists, create it
      connectionFactory = (TopicConnectionFactory)
      ctx.lookup("TopicConnectionFactory");

      connection = connectionFactory.createTopicConnection();
      session = connection.createTopicSession(false,
      Session.AUTO_ACKNOWLEDGE);

      topicAIX = (Topic) ctx.lookup(tNameAIX);
      topicHP = (Topic) ctx.lookup(tNameHP);
      topicLinux = (Topic) ctx.lookup(tNameLinux);
      topicSolaris = (Topic) ctx.lookup(tNameSolaris);
      topicVMS = (Topic) ctx.lookup(tNameVMS);
      topicWin2000 = (Topic) ctx.lookup(tNameWin2000);
      }
      catch (JMSException e) {
      log.error(InitBuildBean.class, "createConnection: "
      + e.getMessage());
      }
      catch (NamingException ne) {
      // THIS EXCEPTION IS BEING THROWN ...
      log.error(InitBuildBean.class, "createConnections: Could not create "
      + "JNDI context");
      }

        • 1. Re: creating multiple topics
          Jon Ferguson Newbie

          Hi.. Are you ensuring the topics are in the JNDI directory?... try this:
          ...
          try{
          _topic = (Topic)ctx.lookup("topic/sometopic");
          }catch(NamingException ne) {
          try{
          _topic = session.createTopic("sometopic");
          ctx.bind("topic/sometopic", _topic);
          }catch(NamingException ne2) {
          ...
          }catch(JMSException jmse) {
          ...
          }
          }
          ..

          • 2. Re: creating multiple topics
            Jon Ferguson Newbie

            Hi, did some tests on my suggestion.. and had probs. I guess JBoss doesn't support this method.. even if using transient topics. So the question is: Did you setup the topic names in the appropriate file (for 2.4.0 its
            jbossmq.xml). Note topics expect the prefix "topic/" cause that's where JBoss puts it into the JNDI tree.

            Hope this helps.

            • 3. Re: creating multiple topics
              Vineet Sharma Newbie

              Hi, Can somebody tell me where are the JNDI bindings set for topic. JBOSS seems to be appending topic/ to the topic names .Am I correct . If i want to look up a topicname without the topic/ appeneded how do i do specify it in jboss.xml .. I mean is there any way by which this appending of "topic/" to the topic name be stopped ..Kindly help

              • 4. Re: creating multiple topics
                Michael Lu Newbie

                Hi,

                You can go to http://localhost:8082/ and open up JNDIView and click on the LIST operation, you can see what are really in there. JBossMQ uses names like topic/testTopic for topic names. And also in the online documentation you can find good examples for JMS, but becareful you are using the correct connection factory. You can also find what is bound there in JNDI for your topic connection factory.