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.
passwordstringno—Optional 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.
source_metadatabooleannofalse(Consumer only) Include authoritative mqb.src.nats_* source positions. Defaults to false.
streamstringno—The 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.
subjectstringno—The 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.
tokenstringno—Optional token for authentication.
urlstringyes—Comma-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.
usernamestringno—Optional 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_filestringno—Path to the CA certificate file.
cert_filestringno—Path to the client certificate file (PEM).
cert_passwordstringno—Password for the private key (if encrypted).
key_filestringno—Path to the client private key file (PEM).
requiredbooleannofalseIf true, enable TLS/SSL.