remove consumerid and add example

Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com>
This commit is contained in:
Hannah Hunter 2023-06-27 15:58:48 -04:00
parent d6ec5e71ef
commit a732ff2fc0
1 changed files with 25 additions and 3 deletions

View File

@ -31,8 +31,6 @@ spec:
value: "/path/to/tls.key"
- name: token # Optional. Used for token based authentication.
value: "my-token"
- name: consumerID
value: "channel1"
- name: name
value: "my-conn-name"
- name: streamName
@ -83,7 +81,6 @@ spec:
| tls_client_cert | N | NATS TLS Client Authentication Certificate | `"/path/to/tls.crt"` |
| tls_client_key | N | NATS TLS Client Authentication Key | `"/path/to/tls.key"` |
| token | N | [NATS token based authentication] | `"my-token"` |
| consumerID | N | Consumer ID (consumer tag) organizes one or more consumers into a group. Consumers with the same consumer ID work as one virtual consumer; for example, a message is processed only once by one of the consumers in the group. If the `consumerID` is not provided, the Dapr runtime set it to the Dapr application ID (`appID`) value. | `"channel1"`
| name | N | NATS connection name | `"my-conn-name"` |
| streamName | N | Name of the JetStream Stream to bind to | `"my-stream"` |
| durableName | N | [Durable name] | `"my-durable"` |
@ -146,6 +143,31 @@ It is essential to create a NATS JetStream for a specific subject. For example,
nats -s localhost:4222 stream add myStream --subjects mySubject
```
## Example: Competing consumers pattern
Let's say you'd like each message to be processed by only one application or pod with the same app-id. Typically, the `consumerID` metadata spec helps you define competing consumers. However, `consumerID` is not supported in NATS JetStream.
The following example demonstrates using a competing consumer pattern with dynamic values.
```yml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: pubsub
spec:
type: pubsub.jetstream
version: v1
metadata:
- name: name
value: "my-conn-name"
- name: streamName
value: "my-stream"
- name: durableName
value: "my-durable"
- name: queueGroupName
value: "my-queue"
```
## Related links
- [Basic schema for a Dapr component]({{< ref component-schema >}})
- Read [this guide]({{< ref "howto-publish-subscribe.md#step-2-publish-a-topic" >}}) for instructions on configuring pub/sub components