1 Reply Latest reply on Jun 7, 2005 10:49 AM by Steven Ostrowski

    EOFException - Subscriber Terminates Immediately

    Jim Cross Newbie

      Hi all,

      Probably a silly error, but I can't find the answer anywhere.
      I've written a small test application which subscribes to a Topic.

      The topic is deployed as:

       <mbean code="org.jboss.mq.server.jmx.Topic"
       name="jboss.mq.destination:service=Topic,name=TasksTopic">
       <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
      
       </mbean>
      


      The code for the subscriber is:
      import javax.naming.*;
      import javax.jms.*;
      
      public class TaskConsumer implements MessageListener {
      
       private TopicConnection conn;
       private Session session;
       private TopicSubscriber sub;
      
       public TaskConsumer() {
      
      
       }
      
       private void init() throws NamingException, JMSException {
       Context ctx = new InitialContext();
       TopicConnectionFactory connFactory = (TopicConnectionFactory)ctx.lookup("ConnectionFactory");
      
       conn = connFactory.createTopicConnection();
       session = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
      
       Topic dest = (Topic)ctx.lookup("topic/TasksTopic");
       sub = session.createDurableSubscriber(dest, "Jim");
       sub.setMessageListener(this);
      
       conn.start();
       }
      
      
       public void onMessage(Message message){
       String text = null;
       try{
       if(message instanceof TextMessage){
       text = ((TextMessage)message).getText();
      
       } else {
       text = message.toString();
       }
       System.out.println("Received: " + text);
      
       } catch (JMSException ex){
       ex.printStackTrace();
       }
       }
      
      
      
       public void close() {
       try{
       sub.close();
       session.close();
       conn.close();
       } catch (JMSException ex){}
       }
      
       public static void main(String[] args){
       TaskConsumer tc = null;
      
       try{
       tc = new TaskConsumer();
       tc.init();
       } catch (Exception ex){
       ex.printStackTrace();
       } finally {
       try{ tc.close(); } catch (Exception ex) {}
       }
       }
      
      
      
      }
      


      When I run this, the client terminates almost immediately. If there are messages there, it consumes them, then terminates (I think).

      In the logs I see the following:
      005-02-14 16:00:06,865 DEBUG [org.jboss.mq.il.uil2.SocketManager] Begin WriteTask.run
      2005-02-14 16:00:06,865 DEBUG [org.jboss.mq.il.uil2.SocketManager] Created ObjectOutputStream
      2005-02-14 16:00:06,865 DEBUG [org.jboss.mq.il.uil2.SocketManager] Created ObjectInputStream
      2005-02-14 16:00:06,881 DEBUG [org.jboss.mq.il.uil2.ServerSocketManagerHandler] Setting up the UILClientIL Connection
      2005-02-14 16:00:06,881 DEBUG [org.jboss.mq.il.uil2.ServerSocketManagerHandler] The UILClientIL Connection is set up
      2005-02-14 16:00:06,881 WARN [org.jboss.resource.security.ConfiguredIdentityLoginModule] Creating LoginModule with no configured password!
      2005-02-14 16:00:06,959 DEBUG [org.jboss.mq.sm.jdbc.JDBCStateManager] Checking durable subscription: DurableSubscription[clientId=ID:36 name=Jim selector=null], on topic: TOPIC.TasksTopic.DurableSubscription[clientId=ID:36 name=Jim selector=null]
      2005-02-14 16:00:06,959 DEBUG [org.jboss.mq.sm.jdbc.JDBCStateManager] The subscription was not previously registered.
      2005-02-14 16:00:06,959 DEBUG [org.jboss.mq.pm.jdbc2.PersistenceManager] Restored 0 message(s) to: TOPIC.TasksTopic.DurableSubscription[clientId=ID:36 name=Jim selector=null]
      2005-02-14 16:00:06,959 DEBUG [org.jboss.mq.il.uil2.SocketManager] End WriteTask.run
      2005-02-14 16:00:06,959 DEBUG [org.jboss.mq.il.uil2.ServerSocketManagerHandler] Exiting on IOE
      java.net.SocketException: socket closed
       at java.net.SocketInputStream.socketRead0(Native Method)
       at java.net.SocketInputStream.read(SocketInputStream.java:129)
       at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
       at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
       at org.jboss.util.stream.NotifyingBufferedInputStream.read(NotifyingBufferedInputStream.java:67)
       at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2133)
       at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2313)
       at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2380)
       at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2452)
       at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2601)
       at java.io.ObjectInputStream.readByte(ObjectInputStream.java:845)
       at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:284)
       at java.lang.Thread.run(Thread.java:534)
      2005-02-14 16:00:06,959 DEBUG [org.jboss.mq.il.uil2.SocketManager] End ReadTask.run
      


      Other times I see this:

      2005-02-14 15:45:48,725 DEBUG [org.jboss.mq.pm.jdbc2.PersistenceManager] Restored 0 message(s) to: TOPIC.TasksTopic.DurableSubscription[clientId=ID:33 name=Jim selector=null]
      2005-02-14 15:45:48,725 DEBUG [org.jboss.mq.il.uil2.ServerSocketManagerHandler] Exiting on IOE
      java.io.EOFException
       at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2603)
       at java.io.ObjectInputStream.readByte(ObjectInputStream.java:845)
       at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:284)
       at java.lang.Thread.run(Thread.java:534)
      


      Any help much appreciated!

      Jim