/// <summary> /// Добавить получатель сообщения. /// </summary> /// <typeparam name="TReceiver">Тип получателя.</typeparam> /// <param name="serviceCollection">Коллекция сервисов.</param> /// <param name="rabbitConfiguration">Конфигурация RabbitMQ.</param> public static void AddMessageReceiver <TReceiver>(this IServiceCollection serviceCollection, RabbitConfiguration rabbitConfiguration) where TReceiver : class, IHostedService { serviceCollection.AddMessageReceiver((serviceProvider, scopeFactory) => (TReceiver)Activator.CreateInstance(typeof(TReceiver), rabbitConfiguration, scopeFactory, serviceProvider.GetService <ILogger <TReceiver> >())); }
public ExposedRabbitService(RabbitConfiguration config) : base(config) { }
public Rabbit(RabbitConfiguration rabbitConfiguration) { this.RabbitConfiguration = rabbitConfiguration; }
//default behaviour of queue service. public virtual IQueueService CreateQueue(RabbitConfiguration config) { return(new QueueService(config, _provider.GetService <ILogger <QueueService> >())); }
public RabbitConsumer(IOptionsMonitor <RabbitConfiguration> rabbitConfigurationOptions, IServiceProvider serviceProvider) { this.rabbitConfiguration = rabbitConfigurationOptions.CurrentValue; this.serviceProvider = serviceProvider; }
public static IBusConfigurator UseRabbitMQTransport(this IBusConfigurator busConfigurator, RabbitConfiguration config) => UseRabbitMQTransport(busConfigurator, config, null);
public StubQueueService(RabbitConfiguration config) { RabbitConfig = config; }
public DataPointPublisher(IOptionsMonitor <RabbitConfiguration> rabbitConfigurationOptions) { this.rabbitConfiguration = rabbitConfigurationOptions.CurrentValue; }
public ExposedQueueService(ILogger <QueueService> logger, RabbitConfiguration rabbitConfig) : base(rabbitConfig, logger) { Consumer = new ExposedConsumer { Model = ExposedChannel }; }
/// <summary> /// Конфигурирует все сервисы приложения. /// </summary> /// <param name="services">Коллекция сервисов.</param> public void ConfigureServices(IServiceCollection services) { ValidatorOptions.LanguageManager.Enabled = false; services.AddCors(options => { options.AddPolicy(CorsPolicyName, builder => builder .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials() .SetIsOriginAllowed(x => true)); }); services.Configure <MongoSettings>(Configuration.GetSection(nameof(MongoSettings)).Bind); services.Configure <EmailSettings>(Configuration.GetSection(nameof(EmailSettings)).Bind); services.AddSingleton <MongoContext>(); services.AddSingleton <IMessageTemplatesRepository, MessageTemplatesRepository>(); services.AddSingleton <ITemplateManager, TemplateManager>(); services.AddControllers(); services.AddAuthentication(); services.AddAuthorization(); services.AddMvcCore(options => options.Filters.Add(typeof(FormatResponseFilter))) .AddNewtonsoftJson() .AddApiExplorer() .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <Startup>()); services.AddScoped <JinjaTemplateEngine>(); services.AddScoped <RazorTemplateEngine>(); services.AddScoped <IEmailBodyGenerator, EmailBodyGenerator>(); var rabbitConfiguration = new RabbitConfiguration(); Configuration.GetSection(nameof(RabbitConfiguration)).Bind(rabbitConfiguration); services.AddMessageReceiver <RabbitMessageReceiver <NotificationMessage <EmailNotificationMessage>, EmailNotificationHandler> >(rabbitConfiguration); services.Configure <AuthorizationSettings>(Configuration.GetSection(nameof(AuthorizationSettings)).Bind); services.AddScoped <IAsyncAuthorizationFilter, JWTAuthorizationFilterAttribute>(); services.AddScoped <IEmailMessageFactory, EmailMessageFactory>(); services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo { Title = "Notification Service", Version = "v1" }); options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { Description = "JWT Authorization header using the Bearer scheme. Example: \"Bearer token\"", Name = "Authorization", In = ParameterLocation.Header, Type = SecuritySchemeType.ApiKey }); options.AddSecurityRequirement(new OpenApiSecurityRequirement { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } }, new List <string>() } }); string xmlCommentsPath = Path.Combine(AppContext.BaseDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"); options.IncludeXmlComments(xmlCommentsPath); }); services.AddFluentEmail(Configuration.GetSection(nameof(SmtpClientSettings)).Get <SmtpClientSettings>()); services.Configure <ApiBehaviorOptions>(o => o.InvalidModelStateResponseFactory = actionContext => new BadRequestObjectResult(actionContext.ModelState).ToFormattedResponse()); services.AddTransient <IValidator <JwtSecurityToken>, JwtSecurityTokenValidator>(); }
public ConnectionManager(RabbitConfiguration configuration) { Configuration = configuration; }