StellaOps.Router.Transport.RabbitMq.Server

Router RabbitMQ transport, server side: the gateway queues and consumers.

PackageStellaOps.Router.Transport.RabbitMq.Server
ComponentRouter
LicenceBUSL-1.1 (Router licence)
Package kindLibrary
Target frameworknet10.0

To add the package to a project, see Installing Stella Ops packages.

Namespaces

NamespaceTypes
StellaOps.Router.Transport.RabbitMq.Server3

StellaOps.Router.Transport.RabbitMq.Server namespace

TypeKindDescription
RabbitMqTransportServerclassRabbitMQ transport server implementation for the gateway.
RabbitMqTransportServerPluginclassPlugin for the server side of the RabbitMQ transport, which a gateway listens with.
RabbitMqTransportServerServiceCollectionExtensionsclassExtension methods for registering the server side of the RabbitMQ transport.

RabbitMqTransportServer class

public sealed class RabbitMqTransportServer : IGatewayConnectionTransportServer, IAsyncDisposable

RabbitMQ transport server implementation for the gateway.

RabbitMqTransportServer(IOptions<RabbitMqTransportOptions>, ILogger<RabbitMqTransportServer>, IFrameEnvelopeVerifier, IFrameEnvelopeSigner) constructor

public RabbitMqTransportServer(IOptions<RabbitMqTransportOptions> options, ILogger<RabbitMqTransportServer> logger, IFrameEnvelopeVerifier? envelopeVerifier = null, IFrameEnvelopeSigner? envelopeSigner = null)

Initializes a new instance of the RabbitMqTransportServerclass.

ConnectionCount property

public int ConnectionCount { get; }

Gets the number of active connections.

TransportType property

public TransportType TransportType { get; }

The transport this server provides.

OnConnection event

public event Action<string, ConnectionState>? OnConnection

Event raised when a connection is established (on first HELLO).

OnDisconnection event

public event Action<string>? OnDisconnection

Event raised when a connection is lost.

OnFrame event

public event Action<string, Frame>? OnFrame

Event raised when a frame is received.

CloseConnection(string) method

public bool CloseConnection(string connectionId)

Closes a connection.

Parameters

Returns

true when the connection existed and was closed.

Remarks

The broker owns the microservice’s queue, so the gateway cannot close it: the logical connection is forgotten and RabbitMqTransportServer.OnDisconnectionis raised. A later HELLO from the same instance registers it again.

DisposeAsync() method

public ValueTask DisposeAsync()

See IAsyncDisposable.DisposeAsync().

GetConnectionState(string) method

public ConnectionState? GetConnectionState(string connectionId)

Gets the connection state by ID.

Parameters

Returns

The connection state, or null if not found.

GetConnections() method

public IEnumerable<ConnectionState> GetConnections()

Gets all active connections.

RemoveConnection(string) method

public void RemoveConnection(string connectionId)

Removes a connection.

Parameters

SendFrameAsync(string, Frame, CancellationToken) method

public Task SendFrameAsync(string connectionId, Frame frame, CancellationToken cancellationToken = default)

Sends a frame to a connection.

Parameters

StartAsync(CancellationToken) method

public Task StartAsync(CancellationToken cancellationToken)

Starts listening for incoming connections.

Parameters

StopAsync(CancellationToken) method

public Task StopAsync(CancellationToken cancellationToken)

Stops accepting new connections.

Parameters

Remarks

Single-flight: the gateway host can stop the server from its hosted service and from container disposal at the same moment, and two concurrent AMQP closes of one connection fail inside the client library. Every caller awaits the first stop.

RabbitMqTransportServerPlugin class

public sealed class RabbitMqTransportServerPlugin : IRouterTransportPlugin

Plugin for the server side of the RabbitMQ transport, which a gateway listens with. The client side is RabbitMqTransportPluginin StellaOps.Router.Transport.RabbitMq; both carry the transport name rabbitmq.

RabbitMqTransportServerPlugin() constructor

public RabbitMqTransportServerPlugin()

Creates an instance of RabbitMqTransportServerPlugin.

DisplayName property

public string DisplayName { get; }

Gets the human-readable display name for this transport.

Mode property

public RouterTransportMode Mode { get; }

Gets the side of the transport this plugin registers: RouterTransportMode.Client, RouterTransportMode.Server, or RouterTransportMode.Both. IRouterTransportPlugin.Register(RouterTransportRegistrationContext)refuses a context that asks for a side outside this value (RouterTransportRegistrationContext.EnsureSupportedBy(IRouterTransportPlugin)).

TransportName property

public string TransportName { get; }

Gets the transport name (e.g., “tcp”, “tls”, “udp”, “rabbitmq”, “inmemory”, “messaging”), shared by the client and the server plugin of one transport.

Register(RouterTransportRegistrationContext) method

public void Register(RouterTransportRegistrationContext context)

Registers transport services into the DI container for the side the context asks for.

Parameters

Exceptions

RabbitMqTransportServerServiceCollectionExtensions class

public static class RabbitMqTransportServerServiceCollectionExtensions

Extension methods for registering the server side of the RabbitMQ transport.

AddRabbitMqTransportServer(IServiceCollection, Action<RabbitMqTransportOptions>) extension method

public static IServiceCollection AddRabbitMqTransportServer(this IServiceCollection services, Action<RabbitMqTransportOptions>? configure = null)

Adds RabbitMQ transport server services to the service collection.

Parameters

Returns

The service collection.