Method RequestManyAsync
RequestManyAsync<TRequest, TReply>(INatsConnection, NatsMsg<TRequest>, INatsSerialize<TRequest>?, INatsDeserialize<TReply>?, NatsPubOpts?, NatsSubOpts?, CancellationToken)
Request and receive zero or more replies from a responder.
public static IAsyncEnumerable<NatsMsg<TReply>> RequestManyAsync<TRequest, TReply>(this INatsConnection nats, NatsMsg<TRequest> msg, INatsSerialize<TRequest>? requestSerializer = null, INatsDeserialize<TReply>? replySerializer = null, NatsPubOpts? requestOpts = null, NatsSubOpts? replyOpts = null, CancellationToken cancellationToken = default)
Parameters
nats
INatsConnectionNATS connection
msg
NatsMsg<TRequest>Message to be sent as request
requestSerializer
INatsSerialize<TRequest>Serializer to use for the request message type.
replySerializer
INatsDeserialize<TReply>Serializer to use for the reply message type.
requestOpts
NatsPubOptsRequest publish options
replyOpts
NatsSubOptsReply handler subscription options
cancellationToken
CancellationTokenCancel 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