The documentation you are viewing is for Dapr v0.11 which is an older version of Dapr. For up-to-date documentation, see the latest version.

NATS streaming

Detailed documentation on the NATS pubsub component

Setup NATS

You can run a NATS server locally using Docker:

docker run -d -name nats-streaming -p 4222:4222 -p 8222:8222 nats-streaming

You can then interact with the server using the client port: localhost:4222.

Install NATS on Kubernetes by using the kubectl:

# Single server NATS

kubectl apply -f

kubectl apply -f

This will install a single NATS-Streaming and Nats into the default namespace. To interact with NATS, find the service with: kubectl get svc stan.

For example, if installing using the example above, the NATS Streaming address would be:


Create a Dapr component

The next step is to create a Dapr component for NATS-Streaming.

Create the following YAML file named nats-stan.yaml:

kind: Component
  name: <NAME>
  namespace: <NAMESPACE>
  type: pubsub.natsstreaming
  version: v1
  - name: natsURL
    value: <REPLACE-WITH-NATS-SERVER-ADDRESS> # Required. example nats://localhost:4222
  - name: natsStreamingClusterID
    value: <REPLACE-WITH-NATS-CLUSTERID> # Required.
    # blow are subscription configuration.
  - name: subscriptionType
    value: <REPLACE-WITH-SUBSCRIPTION-TYPE> # Required. Allowed values: topic, queue.
  - name: deliverNew
    value: true
  # - name: ackWaitTime
    # value: "" # Optional. See:
  # - name: maxInFlight
    # value: "" # Optional. See:
  # - name: durableSubscriptionName
  #   value: ""
  # following subscription options - only one can be used
  # - name: startAtSequence
    # value: 1
  # - name: startWithLastReceived
    # value: false
  # - name: deliverAll
  #   value: false
  # - name: startAtTimeDelta
  #   value: ""
  # - name: startAtTime
  #   value: ""
  # - name: startAtTimeFormat
  #   value: ""

Apply the configuration

Visit this guide for instructions on configuring pub/sub components.

Last modified July 7, 2022: update nav bar v0.11 (#2633) (b309d3d)