Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-6454

Orphaned JMS connections created in endless loop

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 3.0.5
    • 3.1.14, 3.2.1
    • JMS, Transports
    • None
    • Unknown

    Description

      Problem description

      In JMSFactory.createConnection(JMSConfiguration):

      public static Connection createConnection(JMSConfiguration jmsConfig) throws JMSException {
      	String username = jmsConfig.getUserName();
      	ConnectionFactory cf = jmsConfig.getConnectionFactory();
      	Connection connection = username != null 
      		? cf.createConnection(username, jmsConfig.getPassword())
      		: cf.createConnection();
      	if (jmsConfig.getDurableSubscriptionClientId() != null) {
      		connection.setClientID(jmsConfig.getDurableSubscriptionClientId());
      	}
      	return connection;
      }

      there is no exception handling if the clientID fails to be set. Such an exception would exit this method without passing the reference to the just-opened JMS connection to exception handling code (JMSDestination.createTargetDestinationListener()).

      Moreover, JMSDestination.restartConnection() keeps on starting new connections (there is no max attempt restriction!) until it creates one without an exception thrown in the process.

      Now, if the clientID is already connected to the ESB, this creation of new connection will last until server resources are no longer available to the JVM.

      Possible solution

      1. Close the connection if it's not possible to set the specified clientID at the time:
        public static Connection createConnection(JMSConfiguration jmsConfig) throws JMSException {
        	String username = jmsConfig.getUserName();
        	ConnectionFactory cf = jmsConfig.getConnectionFactory();
        	Connection connection = username != null 
        			? cf.createConnection(username, jmsConfig.getPassword()) 
        			: cf.createConnection();
        	if (jmsConfig.getDurableSubscriptionClientId() != null) {
        		try {					connection.setClientID(jmsConfig.getDurableSubscriptionClientId());
        		} catch (InvalidClientIDException e) {
        			connection.close();
        			throw e;
        		}
        	}
        	return connection;
        }
      2. Add a setting to restrict the maximum attempts to restart the connection in JMSDestination.restartConnection() A configurable value would be best, but even a hardcoded.. anything but the practically endless loop

      Attachments

        Issue Links

          Activity

            People

              cschneider Christian Schneider
              wszostak Waldemar Szostak
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: