ServiceCollectionExtensions Class
Definition
- Namespace
- Savvyio.Extensions.DependencyInjection.RabbitMQ
- Assemblies
- Savvyio.Extensions.DependencyInjection.RabbitMQ.dll
Extension methods for the IServiceCollection interface.
public static class ServiceCollectionExtensions
- Inheritance
-
objectServiceCollectionExtensions
Examples
Register RabbitMQ command queues and event buses in the DI container with AddRabbitMqCommandQueue and AddRabbitMqEventBus. Both methods configure AMQP connection settings and register the concrete queue/bus types.
using System;
using Microsoft.Extensions.DependencyInjection;
using Savvyio.Extensions.DependencyInjection;
using Savvyio.Extensions.DependencyInjection.RabbitMQ;
namespace ExampleApp;
public static class RabbitMqRegistration
{
public static IServiceCollection Configure(IServiceCollection services)
{
services.AddSavvyIO();
services.AddRabbitMqCommandQueue(options =>
{
options.AmqpUrl = new Uri("amqp://guest:guest@localhost:5672");
options.QueueName = "account-commands";
options.Durable = true;
});
services.AddRabbitMqEventBus(options =>
{
options.AmqpUrl = new Uri("amqp://guest:guest@localhost:5672");
options.ExchangeName = "account-events";
});
return services;
}
}
Methods
| Name | Description |
|---|---|
| AddRabbitMqCommandQueue(IServiceCollection, Action<RabbitMqCommandQueueOptions>, Action<ServiceOptions>) | Adds an RabbitMqCommandQueue implementation to the specified IServiceCollection. |
| AddRabbitMqCommandQueue<TMarker>(IServiceCollection, Action<RabbitMqCommandQueueOptions<TMarker>>, Action<ServiceOptions>) | Adds an RabbitMqCommandQueue<TMarker> implementation to the specified IServiceCollection. |
| AddRabbitMqEventBus(IServiceCollection, Action<RabbitMqEventBusOptions>, Action<ServiceOptions>) | Adds an RabbitMqEventBus implementation to the specified IServiceCollection. |
| AddRabbitMqEventBus<TMarker>(IServiceCollection, Action<RabbitMqEventBusOptions<TMarker>>, Action<ServiceOptions>) | Adds an RabbitMqEventBus<TMarker> implementation to the specified IServiceCollection. |