postwait / node-amqp

[UNMAINTAINED] node-amqp is an AMQP client for nodejs
MIT License
1.69k stars 357 forks source link

durable subscriptions? #421

Open thebigredgeek opened 8 years ago

thebigredgeek commented 8 years ago

As stated here... http://www.openamq.org/tutorial:transient-subscriptions

Trying to figure out how to accomplish this with Node AMQP.

Scenario:

1) Provider connects to an exchange and begins broadcasting

2) Consumer connects queue to exchange and begins listening 2 minutes later, after some messages have been dispatched by the provider.

3) 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:

1) All consumers go down but providers continue broadcasting. Do the messages simply vanish?

Any tips or insight here would be great.

Cheers, Andrew

daxiang28 commented 8 years ago

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.