-
Notifications
You must be signed in to change notification settings - Fork 637
Direct reply-to still needs correlation ID to work!? #1312
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
Comments
Well, the generated reply-to is tied to a consumer. To avoid the overhead of creating and canceling a consumer for each request, we use a We need the correlation id to detect a late reply for a previous timeout. I suppose we could consider canceling the consumer when we get a timeout instead (since this is an abnormal condition), but that's not the current architecture. |
Actually, you can set |
@garyrussell When I set the |
@igor-susic As i said, we need to be able to detect a late reply for a previously timed-out request. We'd have to change the template to cause the consumer to be canceled instead of returning it to the pool for reuse (when a timeout occurs). Not too difficult to do, but not currently supported; hence I marked this issue as a feature request. |
I understand, I was just noting that for someone else it isn't clear why to use it 🙈 I will probably use this feature for some good load traffic, so maybe In coordination with you I could push some PR when I find time, if you agree. |
Sure; the logic in question is here: spring-amqp/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java Lines 1922 to 1968 in 03fca1d
In the container.releaseConsumerFor(channelHolder, false, null); Where the second parameter is a boolean I think all that needs to be done is, if we timed out (the reply is null), we need to release the consumer with that set to true and an appropriate message in the third parameter to log the reason for the cancel. We should probably make the new capability optional under a new config flag, with the default being the current behavior. The trickier part will be correlating the async reply in |
Sure, I will take a look, and get back to you :) |
Resolves spring-projects#1312 With Direct Reply-To we can correlate the reply using the channel instead of requiring the server to echo back the correlation id.
Resolves spring-projects#1312 With Direct Reply-To we can correlate the reply using the channel instead of requiring the server to echo back the correlation id.
I issued a PR for this #1334 |
Resolves #1312 With Direct Reply-To we can correlate the reply using the channel instead of requiring the server to echo back the correlation id. * Fix link in what's new.
Uh oh!
There was an error while loading. Please reload this page.
When communicating between two different
RabbitMQ
clients and using direct reply-to feature,spring-amqp
project requests message correlation ID to be set. This is not quite how this feature should behave if I understood the documentation well enough.So per direct reply-to documentation when you send request (message) that has property
repy-to
set toamq.rabbitmq.reply-to
then Rabbit will generate some unique string in a way that will look like this:amq.rabbitmq.reply-to.g1hkABlyYWJiaXRAcmFiYml0LXNlY29uZC1ub2RlAAAEBQAAAABgVO6L.dRFik1oCgCYm5rUQycVZ3Q==
which then should be used by the server that will respond by sending it's response to the
""
exchange and with the mentioned unique string as routing key.Nowhere does it asks for correlation ID, it should not be requested as the Rabbit itself can manage pairing request with response with this approach.
Also in spring-amqp documentation for direct repy-to it stands:
and also
This leads me to believe that correlation ID should not come in question in this use case. Spring on the other hand behaves differently.
While sending message it will set the correlation ID to the value of
message tag
this happens at the line 2033 inside RabbitTemplate and when receiving reply it fails on line 615 in RabbitTemplate where it needs correlation ID to proceed.Some code to reproduce this would be:
Java client service as Spring Boot
@Service
bean:Python server service:
Where the trick to get this working is to set correlation ID at the same value that came with the message
Problem with this approach is, that there is no way for someone using Python to know this need of
spring-amqp
because per documentation you don't need to do it, it's enough to setexchange='', routing_key=props.reply_to
.Versions used in this test were:
3.8.9
2.4.4
1.2.0
And sorry for this block of text if I got something wrong 🙇
The text was updated successfully, but these errors were encountered: