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
Clarify intended uses for AsyncRabbitTemplate. #574
Comments
What makes you think the send will block? RabbitMQ is async - although I guess it will block if the broker can't keep up and applies flow control to the connection. It was not the intent of this template to "ignore" conditions when the broker is in a sad state, just to avoid blocking your thread while waiting for a reply. |
To confirm @garyrussell 's comment:
|
@garyrussell @artembilan thanks for the quick response. Sorry, by blocking I meant writing to the socket's OutputStream. I'm in a situation where I'd like to |
Well, Spring AMQP since version Since it isn't there by default you should configure your |
Interesting ok. Maybe if I could be more specific, if I want to send a message during a web request, but I'd rather not block the request, is that the route you'd take (NIO)? I feel like what I need is a way to 'queue' the message, with a separate thread pulling off the queue and sending it. Does that sound like a weird approach? An added constraint is that the message must be guaranteed delivered (thinking publisher confirms.) |
It will be queued in the NIO loop anyway, but doing that manually you are losing context of the We are just sharing with you an info how it works. In the future consider to ask similar question on StackOverflow. |
Yeah, apologies I got off track, thanks for the response. |
Those two requirements are competing. If you hand off to a volatile queue, you can be sure you will lose messages in the event of a server failure. Generally, unless you have a congested network/broker, the send won't block; I fear you are worrying about a situation that is unlikely to occur and, if it does, you have bigger problems than a slow HTTP response. |
Yeah, good point.
Hmm, I don't completely agree. At the end of the day we're talking about writing to a socket. I'd love to assume networking issues won't happen. I'd prefer not to ignore those cases though. Bringing it back to the original issue, when I saw |
I'm trying to better understand the cases for using the AsyncRabbitTemplate. The docs mention that the sendAndRecieve will not block. After reviewing the details of the implementation, it seems the
send
call does block, but the receive will not block. Does that sound right?My initial interpretation was that both send and receive would be async. Would you have any recommendation on doing that? Maybe using
@Async
?The text was updated successfully, but these errors were encountered: