-
Notifications
You must be signed in to change notification settings - Fork 476
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
sendToQueue callback seems to be not called with ConfirmChannel #103
Comments
Yes, one would reasonably expect that to work. What's happening is that the channel is closed before the confirmation comes back -- in fact, the whole program could exit before the confirmation comes back. This is because publish and sendToQueue return immediately, meaning the next thing the program does is close the channel, without waiting for any I/O. One thing you can do (now, in master but not in a release yet) is use
Another possibility is to close the channel in the confirm callback, and link the connection close to the 'close' event on the channel; another is to resolve a promise in the confirm callback, and close the channel in that promise's continuation. But waitForConfirms() seems the most convenient way. |
Thanks @squaremo for the quick reply! So I was using it in the wrong way indeed. :) Anyway, I've tried the solution you've suggested and it works like a charm! |
Weeeelll, it's a pretty subtle problem, which I don't explain very well in documentation. |
Hey Guys, I'm having the similar kind of issue: But in my case the sendToQueue callback runs immediately on client, It suppossed to be run after acknowledge by consumer( ch.ack/ch.nack).
Output: |
@gauravchl If I get this right then this is normal. The Client/Producer puts the messages on the Queues and exits. After this the Worker/Consumer pulls the messages from the Queues and works on them. The ACK messaging is always between a the Producer-Broker and Consumer-Broker. The Producer and Consumer cannot and should not talk to each other. |
@ScOut3R Thanks for the quick reply :)
Then we will have to refactor some unscheduled jobs :) |
Ran into the same issue. The documentation does specify this, but it's easy to miss. We understood this paragraph as, when the worker 'acked', while it is actually referring to the RabbitMQ server. |
I was running into the same error message I have a promise setup within that I resolve it in the consumer:
My issue was I was closing my channel before I resolved. Closing the channel after my resolve fixed my issue. |
@squaremo here's my full example as you've requested:
The channel is indeed working in confirmation mode according to the RabbitMQ admin interface and the message is sent to the queue, but again nothing is logged to the console. Am I using it wrong?
The text was updated successfully, but these errors were encountered: