arobson / rabbot

Deprecated: Please see https://github.com/Foo-Foo-MQ/foo-foo-mq
MIT License
277 stars 129 forks source link

Cannot send persistent message using default exchanges #72

Closed bmatson closed 7 years ago

bmatson commented 7 years ago

Rabbot does not allow you to set the persistent option when sending a message, it allows you the specify persistent when setting up your own exchanges, and honors that when sending the message.

The no-name amq.direct exchange is exposed in rabbot, however because of this behavior you can't use it if you want to send persistent messages. I don't think the "default" exchanges can be modified/defined in Rabbot (at least I haven't found it)....

I'd be happy to shoot over a PR to fix this behavior (basically add a "persistent" option to the publish options, and check both the exchange or the message options being truthy to set the persistent option on publishing).

arobson commented 7 years ago

@bmatson - a PR to add this behavior would be great. Please do include tests. Let me know if I can help by answering questions about anything. Thanks!

bmatson commented 7 years ago

So writing a unit test for this is a bit of a puzzle, since non-persistent messages really cant be "seen" unless either the server restarts and they disappear, or you query the HTTP api to get stats on the queue when the message is there (if you chuck in multiple messages on a queue, but don't receive them, you get a "messages_persistent" count in the queue data).

I had a look at your tests and it doesn't seem like you're hitting the HTTP API anywhere that I could rip-off as an example. Would you be opposed to adding in the request npm package and using it to do the test by querying the queue stats? I know it can also be done using just the node.js http module but it's a bit clunky to use.