Method AddEndpointAsync
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
stringOptional endpoint name.
subject
stringOptional endpoint subject.
queueGroup
stringQueue 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
CancellationTokenA CancellationToken used to stop the endpoint.
Returns
Type Parameters
T
Serialization type for messages received.
Remarks
One of name or subject must be specified.