Skip to main content
Version: 0.7.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—Single NATS server URL, e.g. nats://host:4222. (A comma-separated cluster list is not supported: the string is parsed as one URL and a joined list fails.)
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 auth. Precedence: when both username and password are set they win; the token is used only when username/password are absent.

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.

Read errors​

An ended regular subscription returns Disconnection so the engine reconnects — it does not end the job as if the data had ended. JetStream fetches long-poll with a bounded expires wait, so an idle subject is not re-fetched in a tight loop.