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
subjectstringThe subject to subscribe to.
dataTRequestThe optional request data.
headersNatsHeadersThe optional headers to include with the request.
requestSerializerINatsSerialize<TRequest>The optional serializer for the request data.
replySerializerINatsDeserialize<TReply>The optional deserializer for the reply data.
requestOptsNatsPubOptsThe optional publishing options for the request.
replyOptsNatsSubOptsThe optional subscription options for the reply.
cancellationTokenCancellationTokenThe optional cancellation token.
Returns
- ValueTask<NatsSub<TReply>>
A ValueTask<TResult> representing the asynchronous operation of creating the request subscription.
Type Parameters
TRequestThe type of the request data.
TReplyThe type of the expected reply.