-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Is unconditional acknowledgement in tutorial two the right thing to do? #254
Comments
here is the code to which you refer. I think it's reasonable to change it here and here. We'd be happy to review pull requests in both repositories. What do you think @acogoluegnes ? |
This is not a mistake. This approach can be valid as well: not every delivery should be requeued. Of course, this begs the question "why don't you just use automatic acknowledgements then" and it's fair. Perhaps the approach in #255 makes more sense in a tutorial but the current implementation has its merits as well. |
The code in #255 does not result in delivery requeueing, it just leaves deliveries in limbo upon exception. That is worse than what we currently have. |
What if its turned into a try {
doWork()
}
catch (Exception e){
nack()
return
}
// only pass here if the work was done
ack() |
That would make more sense but note that to RabbitMQ, a positive acknowledgement is no different from a negative one if |
On the tutorials page (java) at https://www.rabbitmq.com/tutorials/tutorial-two-java.html there is an example of how to use Acknowledging. In this example the ack is always send. Shouldn't it be send only if the work succeeds? (I am a beginner at java however I think the finally branch always runs)
I would solve this by taking the code out of the
finally
block and adding acatch
block. Then escape the entire function on an exception indoWork(message)
.Apologies if this should have been posted in another repo, I could not find from which repo the above code example originated.
The text was updated successfully, but these errors were encountered: