Skip to main content
Version: Next
output/natsINPUTBUFFERPROCESSOROUTPUT

NATS

The NATS output publishes messages to a NATS server, either to a regular subject or to a JetStream stream. It supports optional username/password or token authentication.

Configuration​

FieldTypeRequiredDefaultDescription
typestringyes—Fixed value "nats"
urlstringyes—NATS server URL (e.g. nats://localhost:4222).
modeobjectyes—Publishing mode (see below).
authobjectno—Authentication configuration (see below).
value_fieldstringno—Binary or string column whose per-row value becomes that message's payload (a null value or a missing column is an error). When unset, the codec encoding of the batch applies.

mode​

mode is a tagged object (selected by its type field).

FieldTypeRequiredDefaultDescription
typestringyes—regular or jet_stream.
subjectobjectyes—NATS subject to publish to (expression; see below).

subject (Expr<String>)​

FieldTypeRequiredDescription
typestringyesvalue (static) or expr (SQL expression).
valuestringyes (value)Static subject name.
exprstringyes (expr)SQL expression evaluated per message.

An expression must yield a non-null string for every row: a NULL result for any row fails the batch with the expression and the row named (wrap it in COALESCE(expr, 'fallback') or filter such rows upstream).

auth​

FieldTypeRequiredDefaultDescription
usernamestringno—Username (use with password).
passwordstringno—Password (use with username).
tokenstringno—Authentication token.

Only one of username/password or token should be configured; if both are present, username/password takes precedence.

Examples​

Regular subject with username/password​

output:
type: "nats"
url: "nats://localhost:4222"
mode:
type: "regular"
subject:
type: "expr"
expr: "concat('orders.', id)"
auth:
username: "user"
password: "pass"
value_field: "message"

JetStream with token​

output:
type: "nats"
url: "nats://localhost:4222"
mode:
type: "jet_stream"
subject:
type: "value"
value: "orders.new"
auth:
token: "secret-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.