You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RabbitMq supports single active consumer which is useful in my scenario where I run all my consumers in a Pod in Kubernetes with N replicas. For consumers where ordering is necessary, I set appropriate headers to ensure only one consumer will be processing messages (with concurrency of 1) from the queue, while the other consumer will wait for the active consumer to disconnect etc.. This works nicely as for consumers where ordering does not matter, I can increase throughput by increasing replica count.
I was wondering if I were to use this library (and I really LOVE the consumer/publisher abstractions... the best I've seen so far!), can we set single active consumer option or if that's how it works under hood?
I hope my questions makes sense.
The text was updated successfully, but these errors were encountered:
Single active consumer can be enabled when declaring a queue, with the
x-single-active-consumer argument set to true
So you can do that with:
constrabbit=newConnection()// if you just want to create the queue (imperative)awaitrabbit.queueDeclare({queue: 'my-queue',arguments: {'x-single-active-consumer': true}})// or when creating a consumer (declarative)constsub=rabbit.createConsumer({queue: 'my-queue',queueOptions: {durable: true,// etc...arguments: {'x-single-active-consumer': true}},},(msg)=>{console.log(msg)})
I simply haven't added type definitions for all the x- extensions, so you may not see this sort of thing in my generated docs. See also QueueDeclare arguments:
RabbitMq supports single active consumer which is useful in my scenario where I run all my consumers in a Pod in Kubernetes with N replicas. For consumers where ordering is necessary, I set appropriate headers to ensure only one consumer will be processing messages (with concurrency of 1) from the queue, while the other consumer will wait for the active consumer to disconnect etc.. This works nicely as for consumers where ordering does not matter, I can increase throughput by increasing replica count.
I was wondering if I were to use this library (and I really LOVE the consumer/publisher abstractions... the best I've seen so far!), can we set single active consumer option or if that's how it works under hood?
I hope my questions makes sense.
The text was updated successfully, but these errors were encountered: