Skip to main content
Version: 0.6.x
input/natsINPUTBUFFERPROCESSOROUTPUT

NATS

The NATS input connects to a NATS server and supports two modes: regular subscriptions (regular) and JetStream pull consumers (jet_stream). As a channel-based input it follows the engine's cancellation-safety contract: dropping a pending read never loses an already-decoded message (see Input Delivery Semantics).

Configuration​

FieldTypeRequiredDefaultDescription
typestringyes—Constant value "nats"
urlstringyes—NATS server URL, e.g. nats://host:4222; multiple servers separated by commas
modeobjectyes—Operating mode, see table below (tagged enum, distinguished by the type field)
authobjectno—Authentication configuration, see table below

mode (regular)​

FieldTypeRequiredDescription
typestringyes"regular"
subjectstringyesNATS subject to subscribe to
queue_groupstringnoQueue group name

mode (jet_stream)​

FieldTypeRequiredDescription
typestringyes"jet_stream"
streamstringyesStream name
consumer_namestringyesConsumer name
durable_namestringnoDurable consumer name

auth​

FieldTypeRequiredDescription
usernamestringnoUsername
passwordstringnoPassword (used together with username)
tokenstringnoToken; takes precedence over username/password when both are present

Examples​

input:
type: "nats"
url: "nats://localhost:4222"
mode:
type: "regular"
subject: "my.subject"
queue_group: "my_group"
input:
type: "nats"
url: "nats://localhost:4222"
mode:
type: "jet_stream"
stream: "my_stream"
consumer_name: "my_consumer"
durable_name: "my_durable"
auth:
token: "my_token"

TLS​

Use a tls:// URL scheme to connect over TLS (for example tls://nats.example.com:4422); async-nats negotiates TLS natively for tls:// URLs and requires the server to support TLS.