Table of Contents

Method AddEndpointAsync

Namespace
NATS.Client.Services
Assembly
NATS.Client.Services.dll

AddEndpointAsync<T>(Func<NatsSvcMsg<T>, ValueTask>, string?, string?, string?, IDictionary<string, string>?, INatsDeserialize<T>?, CancellationToken)

Adds a new endpoint.

public ValueTask AddEndpointAsync<T>(Func<NatsSvcMsg<T>, ValueTask> handler, string? name = null, string? subject = null, string? queueGroup = null, IDictionary<string, string>? metadata = null, INatsDeserialize<T>? serializer = null, CancellationToken cancellationToken = default)

Parameters

handler Func<NatsSvcMsg<T>, ValueTask>

Callback for handling incoming messages.

name string

Optional endpoint name.

subject string

Optional endpoint subject.

queueGroup string

Queue group name (defaults to service group's).

metadata IDictionary<string, string>

Optional endpoint metadata.

serializer INatsDeserialize<T>

Serializer to use when deserializing incoming messages (defaults to connection's serializer).

cancellationToken CancellationToken

A CancellationToken used to stop the endpoint.

Returns

ValueTask

A ValueTask representing the asynchronous operation.

Type Parameters

T

Serialization type for messages received.

Remarks

One of name or subject must be specified.