2 Replies Latest reply on May 6, 2005 1:22 PM by minmay

    is the JBoss close connection exception the root cause of ma

    minmay

      Hello folks, I have this command, a highly modified version of what
      is written in the JBoss docs.

      It seems to successfully publish messages. Note that transactions are not used in this example. However, the server console shows debug output, an exception in closing a connection. Below is my class. Even lower is a partial listing of the debug output.

      In my humble opinion, this close exception seems like an error. But I can be wrong. Is this exception, thrown within the server, intentional? I know that sometimes, exception handling is an actual part of business logic, and perhaps in this situation it is used to communicate state.

      I would truly appreciate help in this knowledge. I notice that many other post that they are having errors using JMS with transactions. This very well could be the root of the cause. Perhaps, nothing is wrong with the transaction, and the cause is that this close is causing a rollback. Who knows. This is mere speculation.

      package infonet.jms;
      
      import javax.jms.JMSException;
      import javax.jms.Topic;
      import javax.jms.TopicConnection;
      import javax.jms.TopicConnectionFactory;
      import javax.jms.TopicPublisher;
      import javax.jms.TopicSession;
      import javax.jms.TextMessage;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      
      
      /**
       * Publishes a text message to the given topic.
       */
      public class PublisherCommand
      {
       /** topic JNDI Name */
       private String topicJndiName = null;
       /** The message text */
       private String text = null;
       /**
       * Retrieves the message text that will be sent.
       * @return the message.
       */
       public String getText()
       {
       return text;
       }
       /**
       * Sets the message to that will be sent.
       * @param text The message text to send.
       */
       public void setText(String text)
       {
       this.text = text;
       }
       /**
       * Retrieves the topic JNDI name.
       * @return the topic JNDI name.
       */
       public String getTopicJndiName()
       {
       return topicJndiName;
       }
       /**
       * Sets the topic JNDI name.
       * @param topicJndiName the topic JNDI name.
       */
       public void setTopicJndiName(String topicJndiName)
       {
       this.topicJndiName = topicJndiName;
       }
      
       /**
       * Publishes the text message to a topic.
       */
       public void execute() throws JMSException,NamingException
       {
       if (topicJndiName==null || text==null)
       throw new IllegalArgumentException("topic and text must be set");
      
       TopicConnection con = null;
       try
       {
       InitialContext ctx = new InitialContext();
       TopicConnectionFactory tcf = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
       con = tcf.createTopicConnection();
       Topic topic = (Topic) ctx.lookup(topicJndiName);
       TopicSession session = con.createTopicSession(false,TopicSession.AUTO_ACKNOWLEDGE);
       con.start();
       TopicPublisher publisher = session.createPublisher(topic);
       TextMessage message = session.createTextMessage(text);
       publisher.publish(message);
       }
       finally
       {
       if (con!=null)
       con.close();
       }
       }
      
       /**
       * Runs this command for test purposes
       * @param args none requred.
       * @throws Exception
       */
       public static void main(String args[]) throws Exception
       {
       System.out.println("Begin Publsher Command, now=" + System.currentTimeMillis());
      
       PublisherCommand publisher = new PublisherCommand();
       publisher.setTopicJndiName("topic/tmipMQ");
       publisher.setText("A text msg, now=" + System.currentTimeMillis());
      
       try
       {
       publisher.execute();
       }
       catch (JMSException e)
       {
       e.printStackTrace();
       }
       catch (NamingException e)
       {
       e.printStackTrace();
       }
      
       System.out.println("End Publisher Command");
       System.exit(0);
       }
      }
      


      And then the log output:

      2005-05-06 08:32:20,668 DEBUG [org.jboss.mq.il.uil2.SocketManager] Begin ReadTask.run
      2005-05-06 08:32:20,668 DEBUG [org.jboss.mq.il.uil2.SocketManager] Begin WriteTask.run
      2005-05-06 08:32:20,698 DEBUG [org.jboss.mq.il.uil2.SocketManager] Created ObjectOutputStream
      2005-05-06 08:32:20,748 DEBUG [org.jboss.mq.il.uil2.SocketManager] Created ObjectInputStream
      2005-05-06 08:32:20,838 DEBUG [org.jboss.mq.il.uil2.ServerSocketManagerHandler] Setting up the UILClientIL Connection
      2005-05-06 08:32:20,838 DEBUG [org.jboss.mq.il.uil2.ServerSocketManagerHandler] The UILClientIL Connection is set up
      2005-05-06 08:32:21,208 DEBUG [org.jboss.mq.il.uil2.SocketManager] End WriteTask.run
      2005-05-06 08:32:21,208 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:285)
      at java.lang.Thread.run(Thread.java:534)
      2005-05-06 08:32:21,218 DEBUG [org.jboss.mq.il.uil2.SocketManager] End ReadTask.run


      Thank you.

        • 1. Re: is the JBoss close connection exception the root cause o
          thomas.heiss

          HAHA! :)

          Don't let Adrian get very angry about us developers.

          See my posting here, what Adrian told us:

          http://www.jboss.org/index.html?module=bb&op=viewtopic&t=63523

          The same applies to you.

          Summary:

          Don't care about the DEBUG EOFException.

          Thomas

          • 2. Re: is the JBoss close connection exception the root cause o
            minmay

            As much as I would like his help, and believe me, I do want Adrian's help, I think WE developers have a legitimate point.

            Perhaps the debug code is showing an error. Then we are rightfully point it out.

            My question is EXTREMELY legitimate.

            I am asking, is that exception part of the closing logic, or is it an error?
            I think that if it was truly an expected exception, it would be handled properly, with a debug stating that exception was expected. THAT makes more sense to me.

            I did read that post. It states that us developers are laughable because we don't understand the severity levels in the log4j output. Now, I don't want to brag, I am sure the JBoss folks are higher caliber developers than I am. But seriously, spitting out exception messages would be alarming to anybody. If I am architechting a business solution on JBoss JMS, first I build a proof of concept. If THAT point fails, which this exception seems to indicate, then I need to find an alternative. I don't want an alternative though ;) I want JBoss to work properly. I am simply asking, IS THIS THE EXPECTED behaviour?

            Thank you again.