node-amqp
node-amqp copied to clipboard
durable subscriptions?
As stated here... http://www.openamq.org/tutorial:transient-subscriptions
Trying to figure out how to accomplish this with Node AMQP.
Scenario:
-
Provider connects to an exchange and begins broadcasting
-
Consumer connects queue to exchange and begins listening 2 minutes later, after some messages have been dispatched by the provider.
-
Durable messages built up in durable exchange drain into newly connected queue.
The kind of cases I am worried about that I hope can be alleviated by such functionality:
- All consumers go down but providers continue broadcasting. Do the messages simply vanish?
Any tips or insight here would be great.
Cheers, Andrew
I believe you simply set the 'deliveryMode' to 2 when you publish: https://github.com/postwait/node-amqp#exchangepublishroutingkey-message-options-callback
This is better described in the Rabbit.js documentation:
The option 'persistent' relates both to the durable property of queues and to the deliveryMode property given to messages. If a socket is persistent, it will declare queues as durable, and send messages with deliveryMode of 2. The exceptions are SUB sockets, which don't declare their subscription queue as durable, although PUB sockets are allowed to publish persistent (deliveryMode=2) messages; and REQ sockets, which do declare the request queue (that they send to) as durable, but not their own reply queue.