-
Notifications
You must be signed in to change notification settings - Fork 618
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
AMQP-503: Add Blocking Receive to RabbitTemplate #297
Conversation
JIRA: https://jira.spring.io/browse/AMQP-503 Now that the `QueueingConsumer` is no longer deprecated, add `receiveTimeout` to the `RabbitTemplate` to allow for blocking `receive` operations.
} | ||
|
||
/** | ||
* Non-blocking receive with timeout. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without
Pushed |
else { | ||
delivery = consumer.nextDelivery(receiveTimeout); | ||
} | ||
channel.basicCancel(consumer.getConsumerTag()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basicCancel
to prevent the consumption for the next message ?
From other side can't we use shared QueueingConsumer
instance since this operation is blocked?
Or at least lazy-load (TTL removal) per queueName
, but blocked anyway...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, cancel with prefetch = 1 means we'll only fetch 1 message.
I thought about a permanent QC, maybe just for the configured (default) queue (bear in mind people can consume from arbitrary queues), but then we need logic to deal with canceled consumers, etc, etc.
I figured we can keep it simple for now and enhance later if the demand arises.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@artembilan
Why should we set receive timeout globally? Of course, it is handy to have default receiveTimeout
, but it would be useful to have method receive(String queueName, long timeout, TimeUnit unit)
(or receive(queueName, timeoutMillis)
), isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to open a new feature request.
So, merging as is after rebase |
Merged as c1d0cad |
JIRA: https://jira.spring.io/browse/AMQP-503
Now that the
QueueingConsumer
is no longer deprecated, addreceiveTimeout
to theRabbitTemplate
to allow for blockingreceive
operations.