-
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
channel.publish callback is not called #220
Comments
Same problem, publish method always returns Boolean instead Promise. I tried to use both type of channel. |
Only the
If the connection is dropped, you'll find out about it from the Channel and the Connection. In general, |
@squaremo I'm little confused, according to API doc #publish should return Promise or no? |
No, it does not return a promise. http://www.squaremobius.net/amqp.node/channel_api.html#channel_publish |
@squaremo I also faced with this issue, check out followng use cases: channel.publish().then(..)
// => .then is not a function channel.publish(..., cb)
// cb is called So it works with callback interface but not with Promise. |
@hekike I found solution, bad it's hard to find this in api doc.
Example
|
Thanks, it's really helpful. Instead of it, my concern is that the documentation says it's a promise so probably async but it seems to be that not. I belive the issue is the documentation or the @squaremo what do you think? Should it return Promise for the consistent interface or not? |
In AMQP, the
I'm pretty sure it doesn't say that I do understand why folks don't spot that, in the midst of a fair bit of text. Perhaps I can separate out the methods that don't return promises (it's not just publish -- ack and reject too), to make things clearer. |
@squaremo thanks for the clarification. Channel#publish
Promises or callbacks
#publish(exchange, routingKey, content, [options]) Some separation or highlighting would be useful I for me. About the not rpc than why Promise: |
agree with @squaremo ... it shouldnt return a promise if there is no response... |
I think it should be async meaning it should tell if it got send or not (knowing the state of a connection), instead of me having to check if the connection is up, I am trying to see how to handle errors in case a message wasn't sent, I am confused. |
@squaremo the doc also says:
https://www.squaremobius.net/amqp.node/channel_api.html It's a bit confusing which apis have promise interface and which does not. Seems pretty arbitrary. |
I'm using regular channel (not ConfirmChannel), when calling publish with callback - the callback is not being called at all.
Then I used the return value, but even if the RabbitMQ is down the return value is still true, the only thing that stops the publishing is "onError" event being called on the connection.
The Question is: why publish on regular channel does not support callback properly that will return err when the RabbitMQ is down for instance.
The text was updated successfully, but these errors were encountered: