Table of Contents

Method CreateRequestSubAsync

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

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 string

The subject to subscribe to.

data TRequest

The optional request data.

headers NatsHeaders

The 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 NatsPubOpts

The optional publishing options for the request.

replyOpts NatsSubOpts

The optional subscription options for the reply.

cancellationToken CancellationToken

The 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.