Sdílet prostřednictvím


AspireRabbitMQExtensions.AddKeyedRabbitMQClient Method

Definition

Registers RabbitMQ.Client.IConnection as a keyed singleton for the given name in the services provided by the builder. Enables retries, corresponding health check, logging, and telemetry.

public static void AddKeyedRabbitMQClient (this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string name, Action<Aspire.RabbitMQ.Client.RabbitMQClientSettings>? configureSettings = default, Action<RabbitMQ.Client.ConnectionFactory>? configureConnectionFactory = default);
static member AddKeyedRabbitMQClient : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.RabbitMQ.Client.RabbitMQClientSettings> * Action<RabbitMQ.Client.ConnectionFactory> -> unit
<Extension()>
Public Sub AddKeyedRabbitMQClient (builder As IHostApplicationBuilder, name As String, Optional configureSettings As Action(Of RabbitMQClientSettings) = Nothing, Optional configureConnectionFactory As Action(Of ConnectionFactory) = Nothing)

Parameters

builder
IHostApplicationBuilder

The IHostApplicationBuilder to read config from and add services to.

name
String

The name of the component, which is used as the ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section.

configureSettings
Action<RabbitMQClientSettings>

An optional method that can be used for customizing the RabbitMQClientSettings. It's invoked after the settings are read from the configuration.

configureConnectionFactory
Action<RabbitMQ.Client.ConnectionFactory>

An optional method that can be used for customizing the RabbitMQ.Client.ConnectionFactory. It's invoked after the options are read from the configuration.

Remarks

Reads the configuration from "Aspire:RabbitMQ:Client:{name}" section.

Applies to