Table of Contents

Method PublishAsync

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

PublishAsync(string, NatsHeaders?, string?, NatsPubOpts?, CancellationToken)

Publishes an empty message payload to the given subject name, optionally supplying a reply subject.

public ValueTask PublishAsync(string subject, NatsHeaders? headers = null, string? replyTo = null, NatsPubOpts? opts = null, CancellationToken cancellationToken = default)

Parameters

subject string

The destination subject to publish to.

headers NatsHeaders

Optional message headers.

replyTo string

Optional reply-to subject.

opts NatsPubOpts

A NatsPubOpts for publishing options.

cancellationToken CancellationToken

A CancellationToken used to cancel the command.

Returns

ValueTask

A ValueTask that represents the asynchronous send operation.

Remarks

Publishing a sentinel usually means a signal to the given subject which could be used to trigger an action or indicate an event for example and of messages.

PublishAsync<T>(string, T?, NatsHeaders?, string?, INatsSerialize<T>?, NatsPubOpts?, CancellationToken)

Publishes a serializable message payload to the given subject name, optionally supplying a reply subject.

public ValueTask PublishAsync<T>(string subject, T? data, NatsHeaders? headers = null, string? replyTo = null, INatsSerialize<T>? serializer = null, NatsPubOpts? opts = null, CancellationToken cancellationToken = default)

Parameters

subject string

The destination subject to publish to.

data T

Serializable data object.

headers NatsHeaders

Optional message headers.

replyTo string

Optional reply-to subject.

serializer INatsSerialize<T>

Serializer to use for the message type.

opts NatsPubOpts

A NatsPubOpts for publishing options.

cancellationToken CancellationToken

A CancellationToken used to cancel the command.

Returns

ValueTask

A ValueTask that represents the asynchronous send operation.

Type Parameters

T

Specifies the type of data that may be sent to the NATS Server.

PublishAsync<T>(in NatsMsg<T>, INatsSerialize<T>?, NatsPubOpts?, CancellationToken)

Publishes a serializable message payload to the given subject name, optionally supplying a reply subject.

public ValueTask PublishAsync<T>(in NatsMsg<T> msg, INatsSerialize<T>? serializer = null, NatsPubOpts? opts = null, CancellationToken cancellationToken = default)

Parameters

msg NatsMsg<T>

A NatsMsg<T> representing message details.

serializer INatsSerialize<T>

Serializer to use for the message type.

opts NatsPubOpts

A NatsPubOpts for publishing options.

cancellationToken CancellationToken

A CancellationToken used to cancel the command.

Returns

ValueTask

A ValueTask that represents the asynchronous send operation.

Type Parameters

T

Specifies the type of data that may be sent to the NATS Server.