> For the complete documentation index, see [llms.txt](https://docs.natsclub.cn/cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.natsclub.cn/cn/yi-chan/stan/streaming/queues.md).

# Queue Subscriptions

Queue subscriptions are created like other subscriptions with the addition of a queue name.

```go
qsub1, _ := sc.QueueSubscribe(channelName,
    queueName, func(m *stan.Msg) {...})

qsub2, _ := sc.QueueSubscribe(channelName,
    queueName, func(m *stan.Msg) {...})
```

Multiple subscriptions using the same channel and queue name are members of the same queue group. That means that if a message is published on that channel, only one member of the group receives the message. Other subscriptions receive messages independently of the queue groups, that is, a message is delivered to all subscriptions and one member of each queue group.

To create a durable queue subscription, simply add a durable name:

```go
qsub, err := sc.QueueSubscribe(channelName,
    queueName, func(m *stan.Msg) {...},
    stan.DurableName("durable-name"))
```

Subscriptions options apply to each member independently, notably, the `AckWait` and `MaxInflight`. Those two members of the same queue group use different options for redelivery and max inflight.

```go
qsub1, _ := sc.QueueSubscribe(channelName,
    queueName, func(m *stan.Msg) {...},
    stan.AckWait(5*time.Second),
    stan.MaxInflight(5))

qsub2, _ := sc.QueueSubscribe(channelName,
    queueName, func(m *stan.Msg) {...},
    stan.AckWait(20*time.Second),
    stan.MaxInflight(10))
```

If the queue subscription is durable, only the last member calling `Unsubscribe()` will cause the durable queue group to be removed from the server.

Check the [concepts](/cn/yi-chan/stan/intro/channels/subscriptions/queue-group.md) section for more information.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.natsclub.cn/cn/yi-chan/stan/streaming/queues.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
