node-rabbitmq-client icon indicating copy to clipboard operation
node-rabbitmq-client copied to clipboard

Streaming/batched publishers

Open cody-greene opened this issue 1 year ago • 2 comments

In certain cases I'd like to rapidly publish a lot of messages at once, with confirms enabled. Currently this means collecting a bunch of promises and using Promise.all(...). It would be nice if I had a API conforming to the node WritableStream interface (where too many unconfirmed messages creates back-pressure), or maybe just a sendAll(messages) method.

cody-greene avatar Feb 09 '24 04:02 cody-greene

is there something built in to the spec for batch publishing?

dermasmid avatar May 07 '24 21:05 dermasmid

There are some aspects. Transaction-mode exists, but it's mutually exclusive with publisher confirms so I don't recommend it. A single BasicAck from the exchange can (theoretically) confirm multiple messages from the client so just sending everything as fast as possible seems to be the way to go.

Also thinking about this more, the WritableStream interface does not seem a good match for this library. Node streams are fragile (a single error results in a closed stream) but this is designed around recovery, retrying, etc. I think the best option is pub.sendAll(messages)

cody-greene avatar May 17 '24 19:05 cody-greene