8 Replies Latest reply: Jun 4, 2012 10:33 AM by Laura delli Paoli RSS

    Topics with AS7 and HornetQ

    Laura delli Paoli Master

      Hello everybody!

      I'm trying to develop a simple application with a publisher and a subscriber.

      To publish a message I wrote che following instructions:

       

      Properties env = new Properties();

      env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);

      env.put(Context.PROVIDER_URL, PROVIDER_URL);

      env.put(Context.SECURITY_PRINCIPAL, DEFAULT_USERNAME);

      env.put(Context.SECURITY_CREDENTIALS, DEFAULT_PASSWORD);

      env.put("jboss.naming.client.ejb.context", true);

      Context ctx = new InitialContext(env);

      tconFactory = (TopicConnectionFactory) PortableRemoteObject.narrow(ctx.lookup("jms/RemoteConnectionFactory"),TopicConnectionFactory.class);

      tcon = tconFactory.createTopicConnection(DEFAULT_USERNAME,DEFAULT_PASSWORD);

      tsession = tcon.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

      topic = (Topic) PortableRemoteObject.narrow(ctx.lookup("jms/"+topicName), Topic.class);

      tpublisher = tsession.createPublisher(topic);

      msg = tsession.createTextMessage();

      tcon.start();

      System.out.println("Topic Sender");

      System.out.println("Following Messages has been sent !!!");

      System.out.println("====================================");

      for(int j=1;j<=3;j++){

                          msg.setText(""+j);                     // Messages

                          tpublisher.publish(msg);           // Messages sent

                System.out.println("Message Sent = "+j);

      }

      System.out.println("====================================");

       

      When I run these instructions I get no error but I cannot see any message from JBoss  Administration Console. Is there any error?