StellaOps.Router.Transport.RabbitMq
Router RabbitMQ transport, client side: connects a microservice to a gateway through RabbitMQ queues. Install Installing Stella Ops packagesRouter downloads and signaturesnet10.01.0.1-20261117T070237Zdotnet add package StellaOps.
Namespaces
| Namespace | Types |
|---|---|
StellaOps. | 5 |
namespace StellaOps.Router.Transport.RabbitMq
| Type | Kind | Description |
|---|---|---|
RabbitMqFrameProtocol | class | Handles serialization and deserialization of frames for RabbitMQ transport. |
RabbitMqTransportClient | class | RabbitMQ transport client implementation for microservices. |
RabbitMqTransportClientServiceCollectionExtensions | class | Extension methods for registering RabbitMQ transport services. |
RabbitMqTransportOptions | class | Options for RabbitMQ transport configuration. |
RabbitMqTransportPlugin | class | Plugin for the client side of the RabbitMQ transport, which a microservice connects with. |
class RabbitMqFrameProtocol
public static class RabbitMqFrameProtocol
Handles serialization and deserialization of frames for RabbitMQ transport.
Members
| Member | Kind | Summary |
|---|---|---|
CreateProperties( | method | Creates BasicProperties for a frame. |
ExtractConnectionId( | method | Extracts the connection ID from message properties. |
ParseFrame( | method | Parses a frame from a RabbitMQ message. |
method CreateProperties(Frame, string, TimeSpan?) #
CreateProperties(Frame, string, TimeSpan?) #public static BasicProperties CreateProperties(Frame frame, string? replyTo, TimeSpan? timeout = null)
Creates BasicProperties for a frame.
Parameters
frame: The frame to serialize.replyTo: The reply queue name.timeout: Optional timeout for the message.
Returns
The basic properties.
method ExtractConnectionId(IReadOnlyBasicProperties) #
ExtractConnectionId(IReadOnlyBasicProperties) #public static string ExtractConnectionId(IReadOnlyBasicProperties properties)
Extracts the connection ID from message properties.
Parameters
properties: The message properties.
Returns
The connection ID.
method ParseFrame(ReadOnlyMemory<byte>, IReadOnlyBasicProperties) #
ParseFrame(ReadOnlyMemory<byte>, IReadOnlyBasicProperties) #public static Frame ParseFrame(ReadOnlyMemory<byte> body, IReadOnlyBasicProperties properties)
Parses a frame from a RabbitMQ message.
Parameters
body: The message body. The frame keeps a copy: RabbitMQ.Client releases a delivery body when theReceivedAsynchandler returns, and frames are read later.properties: The message properties.
Returns
The parsed frame.
class RabbitMqTransportClient
public sealed class RabbitMqTransportClient : ITransportClient, IMicroserviceTransport, IAsyncDisposable
RabbitMQ transport client implementation for microservices.
Members
constructor RabbitMqTransportClient(IOptions<RabbitMqTransportOptions>, ILogger<RabbitMqTransportClient>, IFrameEnvelopeSigner, IFrameEnvelopeVerifier) #
RabbitMqTransportClient(IOptions<RabbitMqTransportOptions>, ILogger<RabbitMqTransportClient>, IFrameEnvelopeSigner, IFrameEnvelopeVerifier) #public RabbitMqTransportClient(IOptions<RabbitMqTransportOptions> options, ILogger<RabbitMqTransportClient> logger, IFrameEnvelopeSigner? envelopeSigner = null, IFrameEnvelopeVerifier? envelopeVerifier = null)
Initializes a new instance of the RabbitMqTransportClientclass.
event OnCancelReceived #
OnCancelReceived #public event Func<Guid, string?, Task>? OnCancelReceived
Event raised when a CANCEL frame is received.
event OnRequestReceived #
OnRequestReceived #public event Func<Frame, CancellationToken, Task<Frame>>? OnRequestReceived
Event raised when a REQUEST frame is received.
method CancelAllInflight(string) #
CancelAllInflight(string) #public void CancelAllInflight(string reason)
Cancels all in-flight handlers.
method ConnectAsync(InstanceDescriptor, IReadOnlyList<EndpointDescriptor>, CancellationToken) #
ConnectAsync(InstanceDescriptor, IReadOnlyList<EndpointDescriptor>, CancellationToken) #public Task ConnectAsync(InstanceDescriptor instance, IReadOnlyList<EndpointDescriptor> endpoints, CancellationToken cancellationToken)
Connects to the gateway via RabbitMQ.
Parameters
instance: The instance descriptor.endpoints: The endpoints to register.cancellationToken: Cancellation token.
method ConnectAsync(InstanceDescriptor, IReadOnlyList<EndpointDescriptor>, IReadOnlyDictionary<string, SchemaDefinition>, ServiceOpenApiInfo, CancellationToken) #
ConnectAsync(InstanceDescriptor, IReadOnlyList<EndpointDescriptor>, IReadOnlyDictionary<string, SchemaDefinition>, ServiceOpenApiInfo, CancellationToken) #public Task ConnectAsync(InstanceDescriptor instance, IReadOnlyList<EndpointDescriptor> endpoints, IReadOnlyDictionary<string, SchemaDefinition>? schemas, ServiceOpenApiInfo? openApiInfo, CancellationToken cancellationToken)
Connects to the gateway via RabbitMQ and registers the instance, its endpoints, schemas and OpenAPI metadata in the HELLO message.
Parameters
instance: The instance descriptor.endpoints: The endpoints to register.schemas: Schema definitions referenced by the endpoints.openApiInfo: OpenAPI metadata for the service.cancellationToken: Cancellation token.
method DisconnectAsync() #
DisconnectAsync() #public Task DisconnectAsync()
Disconnects from the gateway.
method DisposeAsync() #
DisposeAsync() #public ValueTask DisposeAsync()
See IAsync.
method SendCancelAsync(ConnectionState, Guid, string) #
SendCancelAsync(ConnectionState, Guid, string) #public Task SendCancelAsync(ConnectionState connection, Guid correlationId, string? reason = null)
Sends a cancellation request.
Parameters
connection: The connection to use.correlationId: The correlation ID of the request to cancel.reason: Optional reason for cancellation.
method SendHeartbeatAsync(HeartbeatPayload, CancellationToken) #
SendHeartbeatAsync(HeartbeatPayload, CancellationToken) #public Task SendHeartbeatAsync(HeartbeatPayload heartbeat, CancellationToken cancellationToken)
Sends a heartbeat.
method SendRequestAsync(ConnectionState, Frame, TimeSpan, CancellationToken) #
SendRequestAsync(ConnectionState, Frame, TimeSpan, CancellationToken) #public Task<Frame> SendRequestAsync(ConnectionState connection, Frame requestFrame, TimeSpan timeout, CancellationToken cancellationToken)
Sends a request and waits for a response.
Parameters
connection: The connection to use.requestFrame: The request frame.timeout: The timeout for the request.cancellationToken: Cancellation token.
Returns
The response frame.
method SendStreamingAsync(ConnectionState, Frame, Stream, Func<ResponseFrame, Stream, Task>, PayloadLimits, CancellationToken) #
SendStreamingAsync(ConnectionState, Frame, Stream, Func<ResponseFrame, Stream, Task>, PayloadLimits, CancellationToken) #public Task SendStreamingAsync(ConnectionState connection, Frame requestHeader, Stream requestBody, Func<ResponseFrame, Stream, Task> readResponse, PayloadLimits limits, CancellationToken cancellationToken)
Sends a request whose body is read from a stream and hands the microservice’s response to readResponse. TransportStreamingDispatch.implements it for transports whose microservice side answers a request with one response frame.
Parameters
connection: The connection to use.requestHeader: The request header frame.requestBody: The request body stream.readResponse: Callback that receives the response head (the status code and headers of the microservice’s response; itsResponseFrame.is empty) and the response body stream.Payload limits: Payload limits to enforce.cancellationToken: Cancellation token.
class RabbitMqTransportClientServiceCollectionExtensions
public static class RabbitMqTransportClientServiceCollectionExtensions
Extension methods for registering RabbitMQ transport services.
Members
| Member | Kind | Summary |
|---|---|---|
AddRabbitMqTransportClient( | extension method | Adds RabbitMQ transport client services to the service collection. |
extension method AddRabbitMqTransportClient(IServiceCollection, Action<RabbitMqTransportOptions>) #
AddRabbitMqTransportClient(IServiceCollection, Action<RabbitMqTransportOptions>) #public static IServiceCollection AddRabbitMqTransportClient(this IServiceCollection services, Action<RabbitMqTransportOptions>? configure = null)
Adds RabbitMQ transport client services to the service collection.
Parameters
services: The service collection.configure: Optional configuration action.
Returns
The service collection.
class RabbitMqTransportOptions
public sealed class RabbitMqTransportOptions
Options for RabbitMQ transport configuration.
Members
| Member | Kind | Summary |
|---|---|---|
RabbitMqTransportOptions( | constructor | Creates an instance of Rabbit. |
AutoDeleteQueues | property | Gets or sets whether queues should auto-delete on disconnect. |
AutomaticRecoveryEnabled | property | Gets or sets whether to use automatic recovery. |
DefaultTimeout | property | Gets or sets the default request timeout. |
DurableQueues | property | Gets or sets whether queues should be durable. |
ExchangePrefix | property | Gets or sets the exchange prefix. |
HostName | property | Gets or sets the RabbitMQ host name. |
InstanceId | property | Gets or sets the instance ID for this microservice instance. |
MaxMessageSize | property | Gets or sets the largest message, in bytes, this side publishes; a larger frame is refused before it is published (Payload): the gateway answers 413 for a request and the service 502 for a response, instead of a broker refusal that closes the channel. |
NetworkRecoveryInterval | property | Gets or sets the network recovery interval. |
NodeId | property | Gets or sets the node ID for this gateway instance. |
Password | property | Gets or sets the RabbitMQ password. |
Port | property | Gets or sets the RabbitMQ port. |
PrefetchCount | property | Gets or sets the prefetch count (concurrent messages). |
QueuePrefix | property | Gets or sets the queue prefix. |
RequestExchange | property | Gets or sets the request exchange name. |
ResponseExchange | property | Gets or sets the response exchange name. |
SslCertPath | property | Gets or sets the SSL certificate path. |
UseSsl | property | Gets or sets whether to use SSL/TLS. |
UserName | property | Gets or sets the RabbitMQ username. |
VirtualHost | property | Gets or sets the RabbitMQ virtual host. |
constructor RabbitMqTransportOptions() #
RabbitMqTransportOptions() #public RabbitMqTransportOptions()
Creates an instance of Rabbit.
property AutoDeleteQueues #
AutoDeleteQueues #public bool AutoDeleteQueues { get; set; }
Gets or sets whether queues should auto-delete on disconnect.
property AutomaticRecoveryEnabled #
AutomaticRecoveryEnabled #public bool AutomaticRecoveryEnabled { get; set; }
Gets or sets whether to use automatic recovery.
property DefaultTimeout #
DefaultTimeout #public TimeSpan DefaultTimeout { get; set; }
Gets or sets the default request timeout.
property DurableQueues #
DurableQueues #public bool DurableQueues { get; set; }
Gets or sets whether queues should be durable.
property ExchangePrefix #
ExchangePrefix #public string ExchangePrefix { get; set; }
Gets or sets the exchange prefix.
property HostName #
HostName #public string HostName { get; set; }
Gets or sets the RabbitMQ host name.
property InstanceId #
InstanceId #public string? InstanceId { get; set; }
Gets or sets the instance ID for this microservice instance.
property MaxMessageSize #
MaxMessageSize #public int MaxMessageSize { get; set; }
Gets or sets the largest message, in bytes, this side publishes; a larger frame is refused before it is published (Payload): the gateway answers 413 for a request and the service 502 for a response, instead of a broker refusal that closes the channel. Keep it at or below the broker’s max_message_size. Default: 16 MiB (16777216), the broker default of RabbitMQ 4.
property NetworkRecoveryInterval #
NetworkRecoveryInterval #public TimeSpan NetworkRecoveryInterval { get; set; }
Gets or sets the network recovery interval.
property NodeId #
NodeId #public string? NodeId { get; set; }
Gets or sets the node ID for this gateway instance.
property Password #
Password #public string Password { get; set; }
Gets or sets the RabbitMQ password.
property Port #
Port #public int Port { get; set; }
Gets or sets the RabbitMQ port.
property PrefetchCount #
PrefetchCount #public ushort PrefetchCount { get; set; }
Gets or sets the prefetch count (concurrent messages).
property QueuePrefix #
QueuePrefix #public string QueuePrefix { get; set; }
Gets or sets the queue prefix.
property RequestExchange #
RequestExchange #public string RequestExchange { get; }
Gets or sets the request exchange name.
property ResponseExchange #
ResponseExchange #public string ResponseExchange { get; }
Gets or sets the response exchange name.
property SslCertPath #
SslCertPath #public string? SslCertPath { get; set; }
Gets or sets the SSL certificate path.
property UseSsl #
UseSsl #public bool UseSsl { get; set; }
Gets or sets whether to use SSL/TLS.
property UserName #
UserName #public string UserName { get; set; }
Gets or sets the RabbitMQ username.
property VirtualHost #
VirtualHost #public string VirtualHost { get; set; }
Gets or sets the RabbitMQ virtual host.
class RabbitMqTransportPlugin
public sealed class RabbitMqTransportPlugin : IRouterTransportPlugin
Plugin for the client side of the RabbitMQ transport, which a microservice connects with. The server side is Rabbit in Stella; both carry the transport name rabbitmq.
Members
| Member | Kind | Summary |
|---|---|---|
RabbitMqTransportPlugin( | constructor | Creates an instance of Rabbit. |
DisplayName | property | Gets the human-readable display name for this transport. |
Mode | property | Gets the side of the transport this plugin registers: RouterTransportMode., RouterTransportMode., or RouterTransportMode.. |
TransportName | property | Gets the transport name (e.g., “tcp”, “tls”, “udp”, “rabbitmq”, “inmemory”, “messaging”), shared by the client and the server plugin of one transport. |
Register( | method | Registers transport services into the DI container for the side the context asks for. |
RegisterShared( | method | The registration the client and the server plugin of the RabbitMQ transport share: frame envelope protection and the RabbitMqTransportOptionsbinding of the context’s configuration section (Router:Transport:Rabbit when the context names none). |
constructor RabbitMqTransportPlugin() #
RabbitMqTransportPlugin() #public RabbitMqTransportPlugin()
Creates an instance of Rabbit.
property DisplayName #
DisplayName #public string DisplayName { get; }
Gets the human-readable display name for this transport.
property Mode #
Mode #public RouterTransportMode Mode { get; }
Gets the side of the transport this plugin registers: RouterTransportMode., RouterTransportMode., or RouterTransportMode.. IRouterTransportPlugin.refuses a context that asks for a side outside this value (RouterTransportRegistrationContext.).
property TransportName #
TransportName #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.
method Register(RouterTransportRegistrationContext) #
Register(RouterTransportRegistrationContext) #public void Register(RouterTransportRegistrationContext context)
Registers transport services into the DI container for the side the context asks for.
Parameters
context: The registration context containing services, configuration, and transport mode.
Exceptions
Invalid: The context asks for a side this plugin does not provide.Operation Exception
method RegisterShared(RouterTransportRegistrationContext) #
RegisterShared(RouterTransportRegistrationContext) #public static void RegisterShared(RouterTransportRegistrationContext context)
The registration the client and the server plugin of the RabbitMQ transport share: frame envelope protection and the RabbitMqTransportOptionsbinding of the context’s configuration section (Router:Transport:Rabbit when the context names none). Both plugins call it from RabbitMqTransportPlugin.; a plugin for either side of the transport calls it the same way.
Parameters
context: The registration context of the plugin.