Table of Contents

Method RequestManyAsync

Namespace
NATS.Client.Core
Assembly
NATS.Client.Core.dll

RequestManyAsync<TRequest, TReply>(string, TRequest?, NatsHeaders?, INatsSerialize<TRequest>?, INatsDeserialize<TReply>?, NatsPubOpts?, NatsSubOpts?, CancellationToken)

Request and receive zero or more replies from a responder.

public IAsyncEnumerable<NatsMsg<TReply>> RequestManyAsync<TRequest, TReply>(string subject, TRequest? data, NatsHeaders? headers = null, INatsSerialize<TRequest>? requestSerializer = null, INatsDeserialize<TReply>? replySerializer = null, NatsPubOpts? requestOpts = null, NatsSubOpts? replyOpts = null, CancellationToken cancellationToken = default)

Parameters

subject string

Subject of the responder

data TRequest

Data to send to responder

headers NatsHeaders

Optional message headers

requestSerializer INatsSerialize<TRequest>

Serializer to use for the request message type.

replySerializer INatsDeserialize<TReply>

Serializer to use for the reply message type.

requestOpts NatsPubOpts

Request publish options

replyOpts NatsSubOpts

Reply handler subscription options

cancellationToken CancellationToken

Cancel this request

Returns

IAsyncEnumerable<NatsMsg<TReply>>

An asynchronous enumerable of NatsMsg<T> objects

Type Parameters

TRequest

Request type

TReply

Reply type

Remarks

if reply option's timeout is not defined then it will be set to NatsOpts.RequestTimeout.

Exceptions

OperationCanceledException

Raised when cancellation token is used