private void RegisterCqrsEngine(IReloadingManagerWithConfiguration <BackOfficeBundle> appSettings, ContainerBuilder builder) { builder.Register(context => new AutofacDependencyResolver(context)) .As <IDependencyResolver>() .SingleInstance(); var rabbitSettings = new RabbitMQ.Client.ConnectionFactory { Uri = appSettings.CurrentValue.PayBackOffice.RabbitMq.SagasConnectionString }; builder.RegisterType <EmployeeRegistrationErrorProjection>().SingleInstance(); builder.Register(ctx => { var logFactory = ctx.Resolve <ILogFactory>(); return(new MessagingEngine( logFactory, new TransportResolver(new Dictionary <string, TransportInfo> { { "RabbitMq", new TransportInfo( rabbitSettings.Endpoint.ToString(), rabbitSettings.UserName, rabbitSettings.Password, "None", "RabbitMq") } }), new RabbitMqTransportFactory(logFactory))); }); builder.Register(ctx => new CqrsEngine( ctx.Resolve <ILogFactory>(), ctx.Resolve <IDependencyResolver>(), ctx.Resolve <MessagingEngine>(), new DefaultEndpointProvider(), true, Register.DefaultEndpointResolver(new RabbitMqConventionEndpointResolver( "RabbitMq", Lykke.Messaging.Serialization.SerializationFormat.ProtoBuf, environment: "lykke")), Register.BoundedContext("lykkepay-employee-registration-ui") .PublishingCommands(typeof(RegisterEmployeeCommand), typeof(UpdateEmployeeCommand)) .To("lykkepay-employee-registration") .With("commands") .ListeningEvents(typeof(EmployeeRegistrationFailedEvent), typeof(EmployeeUpdateFailedEvent)) .From("lykkepay-employee-registration") .On("paybo") .WithProjection( typeof(EmployeeRegistrationErrorProjection), "lykkepay-employee-registration") )) .As <ICqrsEngine>() .SingleInstance() .AutoActivate(); }
public Startup(IWebHostEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddEnvironmentVariables(); Configuration = builder.Build(); _appSettings = Configuration.LoadSettings <APIv2Settings>(options => { options.SetConnString(x => x.SlackNotifications.AzureQueue.ConnectionString); options.SetQueueName(x => x.SlackNotifications.AzureQueue.QueueName); options.SenderName = $"{AppEnvironment.Name} {AppEnvironment.Version}"; }); }