Skip to content

When cachemode is connection, setting channel.checkout-timeout will cause the first createConnection to wait for checkout-timeout. #1026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kongwu- opened this issue Jun 15, 2019 · 0 comments · Fixed by #1027
Assignees
Milestone

Comments

@kongwu-
Copy link

kongwu- commented Jun 15, 2019

Bug report

version: 2.1.6-RELEASE

When cachemode is connection, setting channel.checkout-timeout will cause the first createConnection to wait for checkout-timeout ms

application.properties

spring.rabbitmq.addresses=localhost:5672
server.port=8082
spring.rabbitmq.cache.connection.mode=connection
spring.rabbitmq.cache.channel.checkout-timeout=100000

java code

@GetMapping("send")
public String send(String msg){
    // When the first message is sent, createConnection will cause blocking of channel.checkout-timeout ms.
    rabbitTemplate.convertAndSend("test-queue",msg);
    return msg;
}

CachingConnectionFactory#waitForConnection

private ChannelCachingConnectionProxy waitForConnection(long now) {
		ChannelCachingConnectionProxy cachedConnection = null;
                //I think the problem should not wait in this spin-waiting, the first time you create a connection.
		while (cachedConnection == null && System.currentTimeMillis() - now < this.channelCheckoutTimeout) {
			if (countOpenConnections() >= this.connectionLimit) {
				try {
					this.connectionMonitor.wait(this.channelCheckoutTimeout);
					cachedConnection = findIdleConnection();
				}
				catch (InterruptedException e) {
					Thread.currentThread().interrupt();
					throw new AmqpException("Interrupted while waiting for a connection", e);
				}
			}
		}
		return cachedConnection;
	}
@garyrussell garyrussell added this to the 2.1.8 milestone Jun 17, 2019
@garyrussell garyrussell self-assigned this Jun 17, 2019
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Jun 17, 2019
Fixes spring-projects#1026

When using a `channelCheckoutTimeout` with `CacheModeConnection`,
we incorrectly spin waiting for a connection until the timeout
expires.

We should only wait for a connection if the limit is exceeded.

**cherry-pick to all supported**
artembilan pushed a commit that referenced this issue Jun 17, 2019
Fixes #1026

When using a `channelCheckoutTimeout` with `CacheModeConnection`,
we incorrectly spin waiting for a connection until the timeout
expires.

We should only wait for a connection if the limit is exceeded.

**cherry-pick to all supported**
artembilan pushed a commit that referenced this issue Jun 17, 2019
Fixes #1026

When using a `channelCheckoutTimeout` with `CacheModeConnection`,
we incorrectly spin waiting for a connection until the timeout
expires.

We should only wait for a connection if the limit is exceeded.

**cherry-pick to all supported**

(cherry picked from commit dde7a37)
artembilan pushed a commit that referenced this issue Jun 17, 2019
Fixes #1026

When using a `channelCheckoutTimeout` with `CacheModeConnection`,
we incorrectly spin waiting for a connection until the timeout
expires.

We should only wait for a connection if the limit is exceeded.

**cherry-pick to all supported**

(cherry picked from commit dde7a37)

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactory.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactoryTests.java
artembilan pushed a commit that referenced this issue Jun 17, 2019
Fixes #1026

When using a `channelCheckoutTimeout` with `CacheModeConnection`,
we incorrectly spin waiting for a connection until the timeout
expires.

We should only wait for a connection if the limit is exceeded.

**cherry-pick to all supported**

(cherry picked from commit dde7a37)

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactory.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactoryTests.java

# Conflicts:
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactoryTests.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants