在 Nats go 客户端中,我们可以使用 js.AddConsumer() 设置消费者。该函数需要一个 ConsumerConfig。
// ConsumerConfig is the configuration of a JetStream consumer.
type ConsumerConfig struct {
Durable string `json:"durable_name,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
...
Run Code Online (Sandbox Code Playgroud)
现在问题来了。此配置中的 Durable 和 Name 有什么区别?Nats CLI 没有提及单独的名称。只有一个“消费者名称”相当于“持久名称”。
如果我将 Durable 和 Name 设置为不同的值,我会收到此错误:
代码:400 错误代码:10017 = 0x2721 描述:“主题中的消费者名称与请求中的持久名称不匹配”