Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

NATS

Schemes: nats://

Query parameters recognised as config fields for this connector. The object-typed tls is set with a JSON literal, e.g. ?tls={...}. Unrecognised parameters are not forwarded as driver options, so any other ?key=value pair is rejected rather than silently ignored.

NameTypeRequiredDefaultDescription
deduplicatebooleannofalse(Publisher only, JetStream) If true, publish a Nats-Msg-Id header (from the message id) so JetStream deduplicates redeliveries within the stream’s duplicate window. Defaults to false.
delayed_ackbooleannofalse(Publisher only) If true, do not wait for an acknowledgement when sending to broker. Defaults to false.
deliver_policyall | last | new | last_per_subjectno(Consumer only) The delivery policy for the consumer. Defaults to “all”.
no_jetstreambooleannofalseIf no_jetstream: true, use Core NATS (fire-and-forget) instead of JetStream. Defaults to false.
passwordstringnoOptional password for authentication.
prefetch_countintegerno(Consumer only) Number of messages to prefetch from the consumer. Defaults to 10000.
request_replybooleannofalse(Publisher only) If true, the publisher uses the request-reply pattern. It sends a request and waits for a response (using core_client.request_with_headers()). Defaults to false.
request_timeout_msintegerno(Publisher only) Timeout for request-reply operations in milliseconds. Defaults to 30000ms.
sharedbooleannotrueShare one NATS client per connection (default: true); false forces a dedicated connection.
streamstringnoThe JetStream stream name. Required for Consumers, even with no_jetstream: true (unused there, but still validated).
stream_max_bytesintegerno(Publisher only) Maximum total bytes in the stream (if created by the bridge). Defaults to 1GB.
stream_max_messagesintegerno(Publisher only) Maximum number of messages in the stream (if created by the bridge). Defaults to 1,000,000.
subjectstringnoThe NATS subject to publish to or subscribe to. If a stream is auto-created, it’s scoped to {stream}.>, so prefix accordingly.
subscriber_modebooleannofalse(Consumer only) If true, use ephemeral Subscriber mode. Defaults to false (durable consumer).
tlsobjectnosee belowTLS configuration.
tokenstringnoOptional token for authentication.
urlstringyesComma-separated list of NATS server URLs (e.g., “nats://localhost:4222,nats://localhost:4223”). If it contains userinfo, it will be treated as a secret.
usernamestringnoOptional username for authentication.

Struct-typed fields

tls

TLS configuration for secure connections.

Configures Transport Layer Security (TLS/SSL) for encrypted communication. Supports both client certificate (mutual TLS) and server certificate validation.

Examples

use mq_bridge::models::TlsConfig;

let tls = TlsConfig {
    required: true,
    ca_file: Some("/path/to/ca.pem".to_string()),
    cert_file: Some("/path/to/cert.pem".to_string()),
    key_file: Some("/path/to/key.pem".to_string()),
    ..Default::default()
};
NameTypeRequiredDefaultDescription
accept_invalid_certsbooleannofalseIf true, disable server certificate verification (insecure).
ca_filestringnoPath to the CA certificate file.
cert_filestringnoPath to the client certificate file (PEM).
cert_passwordstringnoPassword for the private key (if encrypted).
key_filestringnoPath to the client private key file (PEM).
requiredbooleannofalseIf true, enable TLS/SSL.