Uploaded image for project: 'ServiceMix'
  1. ServiceMix
  2. SM-182

JmsReceicerComponent destroy method can use less JMS close() calls

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.1
    • 2.0.2
    • servicemix-components
    • None

    Description

      In JMS the connection close() also closes all sessions, consumers/producers
      In JMS the session close() also closes all consumers/producers

      See
      http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/Connection.html#close()
      http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/Session.html#close()

      SInce this component is closing everything, really a successful connection.close() is all that is needed. So the JmsReceiverComponent destroy() method can be written to make less API calls as follows:

      public void destroy() throws Exception {
      //PS Fix: START
      /*
      if (consumer != null)

      { consumer.close(); consumer = null; }

      if (session != null)

      { session.close(); session = null; }

      if (connection != null)

      { connection.close(); connection = null; }

      */
      try {
      if (connection != null)

      { connection.close(); }

      else if (session != null)

      { session.close(); }

      else if (consumer != null)

      { consumer.close(); }

      } finally

      { connection = null; session = null; consumer = null; }

      //PS Fix: END
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            peters Peter Samuelson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: