NATS Endpoint

Publish and consume correlated messages over NATS subjects with optional queue groups and auth settings.

Core Fields

Configure ServerUrl, Subject, and Mode. QueueGroup is optional for consumer-side load sharing, and ConnectionName helps trace connections in broker diagnostics.

Authentication

Use UserName + Password for basic auth or Token for token-based auth. Validation blocks invalid combinations so credentials are explicit and transport-safe.

Tracking Extraction

TrackingField and GatherByField use the same header: or json: selector contract as other endpoints. Headers are preserved on produce, and message body parsing supports MessagePayloadType, JsonSettings, and JsonConvertSettings.

Connection Behavior

MaxReconnectAttempts lets you bound reconnect behavior for long-running produce or consume flows while keeping the endpoint contract aligned with the rest of the cross-platform runtime.

Feature Usage Samples

How to use snippets for NATS Endpoint.

Switch between C#, Java, Python, TypeScript, and JavaScript to see the native SDK shape for this sample.

Licensing note: every runnable sample requires a valid runner key via WithRunnerKey("...") or config key LoadStrike:RunnerKey.

NATS Endpoint

var endpoint = new NatsEndpointDefinition
{
    Name = "nats-out",
    Mode = TrafficEndpointMode.Consume,
    TrackingField = TrackingFieldSelector.Parse("header:X-Correlation-Id"),
    ServerUrl = "nats://localhost:4222",
    Subject = "orders.completed",
    QueueGroup = "loadstrike-orders",
    ConnectionName = "orders-consumer"
};

Body Example

ServerUrl

Specifies the NATS server or cluster URL.

Subject

Specifies the NATS subject used to publish or consume messages.

QueueGroup

Lets multiple consumers share work from the same subject when queue semantics are needed.

ConnectionName

Labels the NATS connection for easier broker-side diagnostics.

TrackingField

Points to the header or body field that carries the correlation id.

{ "trackingId": "trk-1", "tenantId": "tenant-a" }

Diagram

NATS endpoint correlation diagram
NATS subjects can be used as producer or consumer endpoints with the same tracking selector contract as other transports.