0

Let`s imagine we have server A with publisher and servers B and C with consumers. Also we have got 5 different subjects; foo1, foo2,... foo5. We always want to send a message only to one consumer and receive only one response.

So we utilize the requestOne function from the JS SDK at the publisher side and subscribe function with the {queue: "default"} option. So both servers B and C has been subscribed one time for each subject. But every time they subscribe they use queue with name "default" to prevent multiple consumers receive the same message as mentioned in docs.

So the question is: Will this queue with name "default" be shared across all the subjects? Or each subject will have his own queue with name "default" and it is just shared between the subscribers of particular subject.

For example: producer generates 10 messages 2 for each subject. Will we have 10 messages processed at the same time or only 2 messages since all the subscription share the same queue with name "default"?

santriseus
  • 106
  • 1
  • 7

2 Answers2

1

You form a queue group based on the queue name that you specify and the subject. So a queue group of "foo" is different than a queue group on "bar".

That being said, with wildcards, you could have multiple subjects being part of the same queue group. That is, 2 members of the group "bar" listening on "foo.*" would split processing of messages sent on "foo.bar", "foo.baz", etc..

I. Kozlovic
  • 796
  • 3
  • 3
1

The same queue name in different subjects is separate.

You can test it with the examples in the link below. https://nats.io/documentation/additional_documentation/nats-queueing/

start nats server

gnatsd

sub subject1

go run nats-qsub.go subject1 default

...

sub subject2

go run nats-qsub.go subject2 default

...

pub subject1&2

go run nats-pub.go subject1 "message"

...

go run nats-pub.go subject2 "message"

...

Community
  • 1
  • 1
GU Ce
  • 11
  • 1