0 Replies Latest reply on Aug 24, 2001 8:50 PM by fede

    Error listening a queue

    fede Newbie

      Hi, i'm testing JBoss 2.4 and
      when i run the simple queue listener client, the program ends after a few seconds and the folowing Exception is thrown in the jboss server console (even when i don't send a message to the queue):

      [Default] Client Connection set spyDistributedConnection, ClientID=ID2. Current
      Thread=Thread[OIL Worker,5,JBossMQ Server Threads]
      [Default] java.net.SocketException: Connection reset by peer: JVM_recv in socket
      input stream read
      [Default] at java.net.SocketInputStream.socketRead(Native Method)
      [Default]
      [Default] at java.net.SocketInputStream.read(SocketInputStream.java:86)
      [Default]
      [Default] at java.io.BufferedInputStream.fill(BufferedInputStream.java:186
      )
      [Default]
      [Default] at java.io.BufferedInputStream.read(BufferedInputStream.java:204
      )
      [Default]
      [Default] at java.io.ObjectInputStream.peekCode(ObjectInputStream.java:154
      9)
      [Default]
      [Default] at java.io.ObjectInputStream.refill(ObjectInputStream.java:1683)

      [Default]
      [Default] at java.io.ObjectInputStream.read(ObjectInputStream.java:1659)
      [Default]
      [Default] at java.io.ObjectInputStream.readByte(ObjectInputStream.java:190
      5)
      [Default]
      [Default] at org.jbossmq.distributed.server.DistributedJMSServerOIL.run(Di
      stributedJMSServerOIL.java:79)
      [Default]
      [Default] at java.lang.Thread.run(Thread.java:484)
      [Default]

      The code is the folowing:
      import javax.jms.*;
      import javax.naming.*;

      public class EscucharMaensage implements javax.jms.MessageListener
      {
      QueueReceiver receiver = null;
      QueueConnection queueConnection = null;

      public EscucharMaensage()
      {
      try
      {
      java.util.Properties p = new java.util.Properties();
      p.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
      p.put("java.naming.provider.url","localhost");
      p.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
      Context ctx = new InitialContext(p);

      QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory)ctx.lookup("QueueConnectionFactory");
      Queue myQueue = (Queue)ctx.lookup("queue/testQueue");
      queueConnection = queueConnectionFactory.createQueueConnection();
      QueueSession queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
      receiver = queueSession.createReceiver(myQueue);
      receiver.setMessageListener(this);
      queueConnection.start();
      }
      catch(Exception exc)
      {
      exc.printStackTrace();
      }


      System.out.println("Escuchando");
      }

      public void onMessage(Message message)
      {
      try
      {
      if (message instanceof TextMessage)
      System.out.println(((TextMessage)message).getText());
      else
      queueConnection.close();
      }
      catch(Exception exc)
      {
      exc.printStackTrace();
      }
      }

      public static void main(String[] args)
      {
      EscucharMaensage escucharMaensage1 = new EscucharMaensage();
      }
      }