Beispiel #1
0
 /// <inheritdoc />
 public RabbitAmqpServer(AmqpServerOptions option, ILogger <RabbitNotificationStorage> log, IAmqpConverter <BasicDeliverEventArgs> converter, IRabbitAmqpCommunication communication)
 {
     _log           = log;
     Features       = new FeatureCollection();
     _converter     = converter;
     _communication = communication;
     _option        = option ?? throw new ArgumentNullException(nameof(option), "Настройки отправки сообщений в RabbitMQ не заданы");
 }
Beispiel #2
0
        /// <summary>
        /// Регистрация Rabbit сервера
        /// </summary>
        /// <param name="services"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static IServiceCollection AddRabbitServer(this IServiceCollection services, AmqpServerOptions options)
        {
            services.AddTransient(provider => options);
            services.TryAddTransient(provider => options.Connection);
            services.TryAddTransient <IRabbitAmqpCommunication, RabbitAmqpCommunication>();
            services.TryAddTransient(provider => options.Connection.ConnectionFactory);
            services.TryAddTransient <IAmqpConverter <BasicDeliverEventArgs>, RabbitAmqpConverter>();
            services.TryAddTransient <IVirtualAmqpServer, VirtualAmqpServer>();
            services.TryAddTransient <IBasicDeliverEventArgsValidator, BasicDeliverEventArgsValidator>();
            services.AddSingleton <IAmqpServer, RabbitAmqpServer>();

            return(services);
        }