You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Freeman Fang (JIRA)" <ji...@apache.org> on 2017/10/27 08:32:00 UTC

[jira] [Updated] (CXF-6454) Orphaned JMS connections created in endless loop

     [ https://issues.apache.org/jira/browse/CXF-6454?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Freeman Fang updated CXF-6454:
------------------------------
    Fix Version/s:     (was: 3.2.0)
                       (was: 3.0.7)
                   3.2.1
                   3.1.14

> Orphaned JMS connections created in endless loop
> ------------------------------------------------
>
>                 Key: CXF-6454
>                 URL: https://issues.apache.org/jira/browse/CXF-6454
>             Project: CXF
>          Issue Type: Bug
>          Components: JMS, Transports
>    Affects Versions: 3.0.5
>            Reporter: Waldemar Szostak
>            Assignee: Christian Schneider
>            Priority: Critical
>             Fix For: 3.1.14, 3.2.1
>
>
> h3. Problem description
> In JMSFactory.createConnection(JMSConfiguration):
> {code}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;
> }{code}
> 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.
> h3. Possible solution
> # Close the connection if it's not possible to set the specified clientID at the time:
> {code}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;
> }{code}
> # 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 ;-)



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)