1 Reply Latest reply on Apr 20, 2004 3:17 AM by Adrian Brock

    jboss 3.2.4 rc1  jms  authenticate  question

    pengpzy Newbie

      Hello:

      I try jms in jboss 3.2.4 rc1 .

      I create two clients,one send and one receive message.

      the sender is:

      public class Sendtest {


      public static void main(String[] args) {
      try {
      Object messaging = null;
      Hashtable hashTab = new Hashtable ();
      hashTab.put(Context.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      if (args.length>0)
      hashTab.put(Context.PROVIDER_URL,args[0]);
      else hashTab.put(Context.PROVIDER_URL,"202.202.202.2:1099");


      InitialContext lContext = new InitialContext(hashTab);

      TopicConnectionFactory Tqcf=
      (TopicConnectionFactory)lContext.lookup("ConnectionFactory");

      TopicConnection topicConnection =Tqcf.createTopicConnection();
      TopicSession session = topicConnection.createTopicSession(false, Session.CLIENT_ACKNOWLEDGE);
      Topic weatherTopic = (Topic) lContext.lookup("topic/testTopic");
      topicConnection.start();

      TopicPublisher publisher = session.createPublisher(weatherTopic);
      TextMessage message = session.createTextMessage();
      message.setText("temperature: 35 degrees");
      publisher.publish(message);

      session.close();
      topicConnection.close();


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

      and the receiver is:

      public class MyTopicSubscriber {

      private static Object session;

      public static void main(String[] args) {
      try {
      Object messaging = null;
      Hashtable hashTab = new Hashtable ();
      hashTab.put(Context.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      if (args.length>0)
      hashTab.put(Context.PROVIDER_URL,args[0]);
      else hashTab.put Context.PROVIDER_URL,"202.202.202.2:1099");

      InitialContext lContext = new InitialContext(hashTab);

      QueueConnectionFactory qcf= (QueueConnectionFactory)lContext.lookup("ConnectionFactory");

      TopicConnectionFactory Tqcf=(TopicConnectionFactory)lContext.lookup("ConnectionFactory");

      TopicConnection topicConnection =Tqcf.createTopicConnection("guest","guest");
      TopicSession session = topicConnection.createTopicSession(false, Session.CLIENT_ACKNOWLEDGE);
      Topic weatherTopic = (Topic) lContext.lookup("topic/testTopic");

      TopicSubscriber topicSubscriber =
      (TopicSubscriber) session.createSubscriber(weatherTopic);

      topicConnection.start();

      TextMessage message= (TextMessage) topicSubscriber.receive();
      System.out.println(message.getText());

      session.close();
      topicConnection.close();
      } catch( Exception e ){e.printStackTrace();}
      }
      }


      the Sendtest.class and MyTopicSubscriber.class run succeed in local machine with the jboss server.

      but when I run the Sendtest.class and MyTopicSubscriber.class on a remote machine (202.202.202.3),the Sendtest.class run succeed and the MyTopicSubscriber.class get an error:

      org.jboss.mq.SpyJMSException: cannot authenticate user; -nseted throwable:
      (java.net.ConnectException:connection refused:connect)
      .......