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 January 30, 2021: Update (#1118) (10c2d21)