Method CreateRequestSubAsync
CreateRequestSubAsync<TRequest, TReply>(string, TRequest?, NatsHeaders?, INatsSerialize<TRequest>?, INatsDeserialize<TReply>?, NatsPubOpts?, NatsSubOpts?, CancellationToken)
Creates a subscription with appropriate request and reply subjects publishing the request. It's the caller's responsibility to retrieve the reply messages and complete the subscription.
ValueTask<NatsSub<TReply>> CreateRequestSubAsync<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
stringThe subject to subscribe to.
data
TRequestThe optional request data.
headers
NatsHeadersThe optional headers to include with the request.
requestSerializer
INatsSerialize<TRequest>The optional serializer for the request data.
replySerializer
INatsDeserialize<TReply>The optional deserializer for the reply data.
requestOpts
NatsPubOptsThe optional publishing options for the request.
replyOpts
NatsSubOptsThe optional subscription options for the reply.
cancellationToken
CancellationTokenThe optional cancellation token.
Returns
- ValueTask<NatsSub<TReply>>
A ValueTask<TResult> representing the asynchronous operation of creating the request subscription.
Type Parameters
TRequest
The type of the request data.
TReply
The type of the expected reply.