13 Replies Latest reply on Aug 20, 2010 3:56 PM by Ian Mitchell

    Basic questions on how to deploy hornetQ Topics on AS 6

    Ian Mitchell Newbie

      Hello all,

       

      Wow - I am missing something very basic here.  I can't seem to find documentation on how to deploy a hornetQ Topic for a simple test application.

       

      Do I still use server/default/deploy/*-service.xml files to describe my Topics?

      What would go in those files?

       

       

      Are there changes to the jndi.properties file or how it used?

       

       

      Would an older (pre-hornetQ) example such as the below snipet still work?

       

      I know theses are a lot of questions (and probably with obvious answers to many of you) so feedback on any of them would be great.

       

      Many thanks

       

      public class Sub {
      TopicConnection conn = null;
      TopicSession session = null;
      Topic topic = null;

      public void setupPubSub()  throws JMSException, NamingException  {
        InitialContext iniCtx = new InitialContext();
        Object tmp = iniCtx.lookup("ConnectionFactory");
        TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
        conn = tcf.createTopicConnection();
        topic = (Topic) iniCtx.lookup("topic/ianTest");
        session = conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
        conn.start();
      }


      public void recvSync()  throws JMSException, NamingException  {
        setupPubSub();
        TopicSubscriber recv = session.createSubscriber(topic);
        Message msg = recv.receive(50000);
        if( msg == null )
         System.out.println("Timed out waiting for msg");
        else
         System.out.println("TopicSubscriber.recv, msgt="+msg);
      }


      public void stop() throws JMSException  {
        conn.stop();
        session.close();
        conn.close();
      }


      public static void main(String args[]) throws Exception  {
        System.out.println("Begin at "+System.currentTimeMillis());
        Sub client = new Sub();
        client.recvSync();
        client.stop();
        System.out.println("Ending");
        System.exit(0);
      }

      }