Table of Contents

Class NatsMessageOptions

Namespace
Savvyio.Extensions.NATS
Assembly
Savvyio.Extensions.NATS.dll

Configuration options that is related to NATS.

public class NatsMessageOptions : IValidatableParameterObject, IParameterObject
Inheritance
NatsMessageOptions
Implements
Derived

Examples

Configure a NatsMessageOptions to point at a NATS server and specify the subject for message delivery.

using System;
using Savvyio.Extensions.NATS;

namespace ExampleApp;

public class NatsSetup
{
    public static NatsMessageOptions CreateOptions()
    {
        var options = new NatsMessageOptions
        {
            NatsUrl = new Uri("nats://localhost:4222"),
            Subject = "account-commands"
        };
        return options;
    }
}

Constructors

NatsMessageOptions()

Initializes a new instance of the NatsMessageOptions class with default values.

public NatsMessageOptions()

Remarks

The following table shows the initial property values for an instance of NatsMessageOptions.

PropertyInitial Value
NatsUrlnew Uri("nats://127.0.0.1:4222")
Subjectnull

Properties

NatsUrl

Gets or sets the URI of the NATS server.

public Uri NatsUrl { get; set; }

Property Value

Uri

Subject

Gets or sets the subject to publish or subscribe to in NATS.

public string Subject { get; set; }

Property Value

string

Methods

ValidateOptions()

Validates the current options and throws an exception if the state is invalid.

public virtual void ValidateOptions()

Exceptions

InvalidOperationException

Subject is null or whitespace - or - NatsUrl is null.

See Also