Skip to content
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

The reply-to container is initialized lazily and shouldn't be binding its routing connection factory key to the calling thread #1091

Closed
jandres80 opened this issue Sep 13, 2019 · 2 comments · Fixed by #1092

Comments

@jandres80
Copy link

Affects Version(s): <2.1.6>

Getting "IllegalArgumentException" errors trying to do the following:

Receive an AMQP message that forces me to stop a "SimpleMessageListenerContainer".
Make an AMQP request using the "direct reply-to" mechanism.
Restart the "SimpleMessageListenerContainer"

More details in:

https://stackoverflow.com/questions/57906682/simplemessagelistenercontainer-and-illegalargumentexception


@garyrussell garyrussell added this to the 2.1.11 milestone Sep 13, 2019
@garyrussell garyrussell self-assigned this Sep 13, 2019
@garyrussell
Copy link
Contributor

Can you explain your use of the RoutingConnectionFactory? Please show its configuration.

It turns out that this code is required in order to use the correct targetConnectionFactory when running a connection listener (if present). Orignal SO issue here.

The problem is that the RoutingConnectionFactory's routingLookupKey is bound to the thread with the SMLC's queue name and we can't rebind it with another key (for the DRTMLC). In any case, I suspect you won't get a hit on the lookup anyway (unless you have configured that key as well in the RCF).

Is there any way you can avoid using the simpleRoutingConnectionFactory() in the template for the send and receive?

@garyrussell garyrussell changed the title The reply-to container is initialized lazily and shouldn't be binding its connection factory to the calling thread The reply-to container is initialized lazily and shouldn't be binding its routing connection factory key to the calling thread Sep 13, 2019
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Sep 13, 2019
Fixes spring-projects#1091

The DMLC can open a connection on the calling thread (e.g. `start()`, `setConsumersPerQueue()`).

When using a routing connection factory, the factory key is temporarily bound to the thread for
proper CF selection in connection listeners (e.g. `RabbitAdmin`).

This is disallowed if the calling thread is, itself, a listener container thread.

Add `push/pop` operations to `SimpleResourceHolder`.

**cherry-pick to 2.1.x**
@garyrussell
Copy link
Contributor

I found a solution.

garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Sep 13, 2019
Fixes spring-projects#1091

The DMLC can open a connection on the calling thread (e.g. `start()`, `setConsumersPerQueue()`).

When using a routing connection factory, the factory key is temporarily bound to the thread for
proper CF selection in connection listeners (e.g. `RabbitAdmin`).

This is disallowed if the calling thread is, itself, a listener container thread.

Add `push/pop` operations to `SimpleResourceHolder`.

**cherry-pick to 2.1.x**
artembilan pushed a commit that referenced this issue Sep 13, 2019
Fixes #1091

The DMLC can open a connection on the calling thread (e.g. `start()`, `setConsumersPerQueue()`).

When using a routing connection factory, the factory key is temporarily bound to the thread for
proper CF selection in connection listeners (e.g. `RabbitAdmin`).

This is disallowed if the calling thread is, itself, a listener container thread.

Add `push/pop` operations to `SimpleResourceHolder`.

**cherry-pick to 2.1.x**
artembilan pushed a commit that referenced this issue Sep 13, 2019
Fixes #1091

The DMLC can open a connection on the calling thread (e.g. `start()`, `setConsumersPerQueue()`).

When using a routing connection factory, the factory key is temporarily bound to the thread for
proper CF selection in connection listeners (e.g. `RabbitAdmin`).

This is disallowed if the calling thread is, itself, a listener container thread.

Add `push/pop` operations to `SimpleResourceHolder`.

**cherry-pick to 2.1.x**
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