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
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| type | string | yes | — | Constant value "nats" |
| url | string | yes | — | 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.) |
| mode | object | yes | — | Operating mode, see table below (tagged enum, distinguished by the type field) |
| auth | object | no | — | Authentication configuration, see table below |
mode (regular)
| Field | Type | Required | Description |
|---|---|---|---|
| type | string | yes | "regular" |
| subject | string | yes | NATS subject to subscribe to |
| queue_group | string | no | Queue group name |
mode (jet_stream)
| Field | Type | Required | Description |
|---|---|---|---|
| type | string | yes | "jet_stream" |
| stream | string | yes | Stream name |
| consumer_name | string | yes | Consumer name |
| durable_name | string | no | Durable consumer name |
auth
| Field | Type | Required | Description |
|---|---|---|---|
| username | string | no | Username |
| password | string | no | Password (used together with username) |
| token | string | no | Token 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.