Merge pull request #23564 from jkhoward
* pr/23564: Polish "Add configuration option for channelRpcTimeout" Add configuration option for channelRpcTimeout Closes gh-23564
This commit is contained in:
		
						commit
						2ab2cf061f
					
				|  | @ -149,6 +149,8 @@ public class RabbitAutoConfiguration { | |||
| 			} | ||||
| 			map.from(properties::getConnectionTimeout).whenNonNull().asInt(Duration::toMillis) | ||||
| 					.to(factory::setConnectionTimeout); | ||||
| 			map.from(properties::getChannelRpcTimeout).whenNonNull().asInt(Duration::toMillis) | ||||
| 					.to(factory::setChannelRpcTimeout); | ||||
| 			map.from(credentialsProvider::getIfUnique).whenNonNull().to(factory::setCredentialsProvider); | ||||
| 			map.from(credentialsRefreshService::getIfUnique).whenNonNull().to(factory::setCredentialsRefreshService); | ||||
| 			factory.afterPropertiesSet(); | ||||
|  |  | |||
|  | @ -120,6 +120,11 @@ public class RabbitProperties { | |||
| 	 */ | ||||
| 	private Duration connectionTimeout; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Continuation timeout for RPC calls in channels. Set it to zero to wait forever. | ||||
| 	 */ | ||||
| 	private Duration channelRpcTimeout = Duration.ofMinutes(10); | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Cache configuration. | ||||
| 	 */ | ||||
|  | @ -336,6 +341,14 @@ public class RabbitProperties { | |||
| 		this.connectionTimeout = connectionTimeout; | ||||
| 	} | ||||
| 
 | ||||
| 	public Duration getChannelRpcTimeout() { | ||||
| 		return this.channelRpcTimeout; | ||||
| 	} | ||||
| 
 | ||||
| 	public void setChannelRpcTimeout(Duration channelRpcTimeout) { | ||||
| 		this.channelRpcTimeout = channelRpcTimeout; | ||||
| 	} | ||||
| 
 | ||||
| 	public Cache getCache() { | ||||
| 		return this.cache; | ||||
| 	} | ||||
|  |  | |||
|  | @ -108,6 +108,8 @@ class RabbitAutoConfigurationTests { | |||
| 					.isEqualTo(com.rabbitmq.client.ConnectionFactory.DEFAULT_CHANNEL_MAX); | ||||
| 			assertThat(connectionFactory.isPublisherConfirms()).isFalse(); | ||||
| 			assertThat(connectionFactory.isPublisherReturns()).isFalse(); | ||||
| 			assertThat(connectionFactory.getRabbitConnectionFactory().getChannelRpcTimeout()) | ||||
| 					.isEqualTo(com.rabbitmq.client.ConnectionFactory.DEFAULT_CHANNEL_RPC_TIMEOUT); | ||||
| 			assertThat(context.containsBean("rabbitListenerContainerFactory")) | ||||
| 					.as("Listener container factory should be created by default").isTrue(); | ||||
| 		}); | ||||
|  | @ -140,7 +142,7 @@ class RabbitAutoConfigurationTests { | |||
| 				.withPropertyValues("spring.rabbitmq.host:remote-server", "spring.rabbitmq.port:9000", | ||||
| 						"spring.rabbitmq.address-shuffle-mode=random", "spring.rabbitmq.username:alice", | ||||
| 						"spring.rabbitmq.password:secret", "spring.rabbitmq.virtual_host:/vhost", | ||||
| 						"spring.rabbitmq.connection-timeout:123") | ||||
| 						"spring.rabbitmq.connection-timeout:123", "spring.rabbitmq.channel-rpc-timeout:140") | ||||
| 				.run((context) -> { | ||||
| 					CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.class); | ||||
| 					assertThat(connectionFactory.getHost()).isEqualTo("remote-server"); | ||||
|  | @ -150,6 +152,7 @@ class RabbitAutoConfigurationTests { | |||
| 					assertThat(connectionFactory.getVirtualHost()).isEqualTo("/vhost"); | ||||
| 					com.rabbitmq.client.ConnectionFactory rcf = connectionFactory.getRabbitConnectionFactory(); | ||||
| 					assertThat(rcf.getConnectionTimeout()).isEqualTo(123); | ||||
| 					assertThat(rcf.getChannelRpcTimeout()).isEqualTo(140); | ||||
| 					assertThat((List<Address>) ReflectionTestUtils.getField(connectionFactory, "addresses")).hasSize(1); | ||||
| 				}); | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue