Deprecate PooledConnectionFactory properties
This commit deprecated the properties of `PooledConnectionFactory` that are no longer supported by an alternative that is a JMS 2 compliant. This commit also adds a note to warn users that this pool implementation is not JMS 2 compliant. Closes gh-13956
This commit is contained in:
		
							parent
							
								
									be2c7bf6ea
								
							
						
					
					
						commit
						d31f68380a
					
				|  | @ -21,6 +21,7 @@ import java.util.ArrayList; | |||
| import java.util.List; | ||||
| 
 | ||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||||
| import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; | ||||
| 
 | ||||
| /** | ||||
|  * Configuration properties for ActiveMQ. | ||||
|  | @ -228,6 +229,7 @@ public class ActiveMQProperties { | |||
| 			this.blockIfFullTimeout = blockIfFullTimeout; | ||||
| 		} | ||||
| 
 | ||||
| 		@DeprecatedConfigurationProperty | ||||
| 		public boolean isCreateConnectionOnStartup() { | ||||
| 			return this.createConnectionOnStartup; | ||||
| 		} | ||||
|  | @ -236,6 +238,7 @@ public class ActiveMQProperties { | |||
| 			this.createConnectionOnStartup = createConnectionOnStartup; | ||||
| 		} | ||||
| 
 | ||||
| 		@DeprecatedConfigurationProperty(reason = "Use idle-timeout instead") | ||||
| 		public Duration getExpiryTimeout() { | ||||
| 			return this.expiryTimeout; | ||||
| 		} | ||||
|  | @ -269,6 +272,7 @@ public class ActiveMQProperties { | |||
| 			this.maximumActiveSessionPerConnection = maximumActiveSessionPerConnection; | ||||
| 		} | ||||
| 
 | ||||
| 		@DeprecatedConfigurationProperty(reason = "Disabling this option will likely lead to broken connections in the pool.") | ||||
| 		public boolean isReconnectOnException() { | ||||
| 			return this.reconnectOnException; | ||||
| 		} | ||||
|  |  | |||
|  | @ -138,10 +138,6 @@ public class ActiveMQAutoConfigurationTests { | |||
| 					assertThat(connectionFactory.getBlockIfSessionPoolIsFullTimeout()) | ||||
| 							.isEqualTo( | ||||
| 									defaultFactory.getBlockIfSessionPoolIsFullTimeout()); | ||||
| 					assertThat(connectionFactory.isCreateConnectionOnStartup()) | ||||
| 							.isEqualTo(defaultFactory.isCreateConnectionOnStartup()); | ||||
| 					assertThat(connectionFactory.getExpiryTimeout()) | ||||
| 							.isEqualTo(defaultFactory.getExpiryTimeout()); | ||||
| 					assertThat(connectionFactory.getIdleTimeout()) | ||||
| 							.isEqualTo(defaultFactory.getIdleTimeout()); | ||||
| 					assertThat(connectionFactory.getMaxConnections()) | ||||
|  | @ -149,8 +145,6 @@ public class ActiveMQAutoConfigurationTests { | |||
| 					assertThat(connectionFactory.getMaximumActiveSessionPerConnection()) | ||||
| 							.isEqualTo(defaultFactory | ||||
| 									.getMaximumActiveSessionPerConnection()); | ||||
| 					assertThat(connectionFactory.isReconnectOnException()) | ||||
| 							.isEqualTo(defaultFactory.isReconnectOnException()); | ||||
| 					assertThat(connectionFactory.getTimeBetweenExpirationCheckMillis()) | ||||
| 							.isEqualTo( | ||||
| 									defaultFactory.getTimeBetweenExpirationCheckMillis()); | ||||
|  | @ -159,18 +153,35 @@ public class ActiveMQAutoConfigurationTests { | |||
| 				}); | ||||
| 	} | ||||
| 
 | ||||
| 	@Test | ||||
| 	@Deprecated | ||||
| 	public void defaultPooledConnectionFactoryIsAppliedWithDeprecatedSettings() { | ||||
| 		this.contextRunner.withUserConfiguration(EmptyConfiguration.class) | ||||
| 				.withPropertyValues("spring.activemq.pool.enabled=true") | ||||
| 				.run((context) -> { | ||||
| 					assertThat(context.getBeansOfType(PooledConnectionFactory.class)) | ||||
| 							.hasSize(1); | ||||
| 					PooledConnectionFactory connectionFactory = context | ||||
| 							.getBean(PooledConnectionFactory.class); | ||||
| 					PooledConnectionFactory defaultFactory = new PooledConnectionFactory(); | ||||
| 					assertThat(connectionFactory.isCreateConnectionOnStartup()) | ||||
| 							.isEqualTo(defaultFactory.isCreateConnectionOnStartup()); | ||||
| 					assertThat(connectionFactory.getExpiryTimeout()) | ||||
| 							.isEqualTo(defaultFactory.getExpiryTimeout()); | ||||
| 					assertThat(connectionFactory.isReconnectOnException()) | ||||
| 							.isEqualTo(defaultFactory.isReconnectOnException()); | ||||
| 				}); | ||||
| 	} | ||||
| 
 | ||||
| 	@Test | ||||
| 	public void customPooledConnectionFactoryIsApplied() { | ||||
| 		this.contextRunner.withUserConfiguration(EmptyConfiguration.class) | ||||
| 				.withPropertyValues("spring.activemq.pool.enabled=true", | ||||
| 						"spring.activemq.pool.blockIfFull=false", | ||||
| 						"spring.activemq.pool.blockIfFullTimeout=64", | ||||
| 						"spring.activemq.pool.createConnectionOnStartup=false", | ||||
| 						"spring.activemq.pool.expiryTimeout=4096", | ||||
| 						"spring.activemq.pool.idleTimeout=512", | ||||
| 						"spring.activemq.pool.maxConnections=256", | ||||
| 						"spring.activemq.pool.maximumActiveSessionPerConnection=1024", | ||||
| 						"spring.activemq.pool.reconnectOnException=false", | ||||
| 						"spring.activemq.pool.timeBetweenExpirationCheck=2048", | ||||
| 						"spring.activemq.pool.useAnonymousProducers=false") | ||||
| 				.run((context) -> { | ||||
|  | @ -181,19 +192,35 @@ public class ActiveMQAutoConfigurationTests { | |||
| 					assertThat(connectionFactory.isBlockIfSessionPoolIsFull()).isFalse(); | ||||
| 					assertThat(connectionFactory.getBlockIfSessionPoolIsFullTimeout()) | ||||
| 							.isEqualTo(64); | ||||
| 					assertThat(connectionFactory.isCreateConnectionOnStartup()).isFalse(); | ||||
| 					assertThat(connectionFactory.getExpiryTimeout()).isEqualTo(4096); | ||||
| 					assertThat(connectionFactory.getIdleTimeout()).isEqualTo(512); | ||||
| 					assertThat(connectionFactory.getMaxConnections()).isEqualTo(256); | ||||
| 					assertThat(connectionFactory.getMaximumActiveSessionPerConnection()) | ||||
| 							.isEqualTo(1024); | ||||
| 					assertThat(connectionFactory.isReconnectOnException()).isFalse(); | ||||
| 					assertThat(connectionFactory.getTimeBetweenExpirationCheckMillis()) | ||||
| 							.isEqualTo(2048); | ||||
| 					assertThat(connectionFactory.isUseAnonymousProducers()).isFalse(); | ||||
| 				}); | ||||
| 	} | ||||
| 
 | ||||
| 	@Test | ||||
| 	@Deprecated | ||||
| 	public void customPooledConnectionFactoryIsAppliedWithDeprecatedSettings() { | ||||
| 		this.contextRunner.withUserConfiguration(EmptyConfiguration.class) | ||||
| 				.withPropertyValues("spring.activemq.pool.enabled=true", | ||||
| 						"spring.activemq.pool.createConnectionOnStartup=false", | ||||
| 						"spring.activemq.pool.expiryTimeout=4096", | ||||
| 						"spring.activemq.pool.reconnectOnException=false") | ||||
| 				.run((context) -> { | ||||
| 					assertThat(context.getBeansOfType(PooledConnectionFactory.class)) | ||||
| 							.hasSize(1); | ||||
| 					PooledConnectionFactory connectionFactory = context | ||||
| 							.getBean(PooledConnectionFactory.class); | ||||
| 					assertThat(connectionFactory.isCreateConnectionOnStartup()).isFalse(); | ||||
| 					assertThat(connectionFactory.getExpiryTimeout()).isEqualTo(4096); | ||||
| 					assertThat(connectionFactory.isReconnectOnException()).isFalse(); | ||||
| 				}); | ||||
| 	} | ||||
| 
 | ||||
| 	@Test | ||||
| 	public void pooledConnectionFactoryConfiguration() { | ||||
| 		this.contextRunner.withUserConfiguration(EmptyConfiguration.class) | ||||
|  |  | |||
|  | @ -941,13 +941,10 @@ content into your application. Rather, pick only the properties that you need. | |||
| 	spring.activemq.packages.trusted= # Comma-separated list of specific packages to trust (when not trusting all packages). | ||||
| 	spring.activemq.pool.block-if-full=true # Whether to block when a connection is requested and the pool is full. Set it to false to throw a "JMSException" instead. | ||||
| 	spring.activemq.pool.block-if-full-timeout=-1ms # Blocking period before throwing an exception if the pool is still full. | ||||
| 	spring.activemq.pool.create-connection-on-startup=true # Whether to create a connection on startup. Can be used to warm up the pool on startup. | ||||
| 	spring.activemq.pool.enabled=false # Whether a PooledConnectionFactory should be created, instead of a regular ConnectionFactory. | ||||
| 	spring.activemq.pool.expiry-timeout=0ms # Connection expiration timeout. | ||||
| 	spring.activemq.pool.idle-timeout=30s # Connection idle timeout. | ||||
| 	spring.activemq.pool.max-connections=1 # Maximum number of pooled connections. | ||||
| 	spring.activemq.pool.maximum-active-session-per-connection=500 # Maximum number of active sessions per connection. | ||||
| 	spring.activemq.pool.reconnect-on-exception=true # Reset the connection when a "JMSException" occurs. | ||||
| 	spring.activemq.pool.time-between-expiration-check=-1ms # Time to sleep between runs of the idle connection eviction thread. When negative, no idle connection eviction thread runs. | ||||
| 	spring.activemq.pool.use-anonymous-producers=true # Whether to use only one anonymous "MessageProducer" instance. Set it to false to create one "MessageProducer" every time one is required. | ||||
| 
 | ||||
|  |  | |||
|  | @ -5049,6 +5049,8 @@ accordingly, as shown in the following example: | |||
| 	spring.activemq.pool.max-connections=50 | ||||
| ---- | ||||
| 
 | ||||
| WARNING: `PooledConnectionFactory` is not JMS 2.0 compliant | ||||
| 
 | ||||
| TIP: See | ||||
| {sc-spring-boot-autoconfigure}/jms/activemq/ActiveMQProperties.{sc-ext}[`ActiveMQProperties`] | ||||
| for more of the supported options. You can also register an arbitrary number of beans | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue