public static MassTransitConfiguration GetMassTransitConfiguration(this IConfiguration configuration) { var hostConfig = new MassTransitConfiguration(); configuration.GetSection(MassTransit).Bind(hostConfig); return(hostConfig); }
public async Task SendBookRequest(int booksCount) { var message = new BooksRequest(booksCount); var hostConfig = new MassTransitConfiguration(); _configuration.GetSection("MassTransit").Bind(hostConfig); var endpoint = await _sendEndpointProvider.GetSendEndpoint(hostConfig.GetQueueAddress("book-shop-queue")); await endpoint.Send(message); }
public async Task SendBooksToQueue(List <IBooksResponse.Book> books) { var message = new BooksResponse { Books = books }; var hostConfig = new MassTransitConfiguration(); _configuration.GetSection("MassTransit").Bind(hostConfig); var endpoint = await _sendEndpointProvider.GetSendEndpoint(hostConfig.GetQueueAddress("books-delivery-queue")); await endpoint.Send(message); }
public async Task SentBookRequest(int bookCount) { Console.Out.WriteLine("Запрос на книги"); var message = new BookRequest(bookCount); var hostConfig = new MassTransitConfiguration(); _configuration.GetSection("MassTransit").Bind(hostConfig); var endpoint = await _sendEndpointProvider.GetSendEndpoint(hostConfig.GetQueueAddress("book-shop-queue")); await endpoint.Send(message); }
public void ConfigureServices(IServiceCollection services) { PrometheusMetrics.TryConfigure(Environment.ApplicationName); MapEvents(); var esConnection = ConfigureEsConnection( Configuration["EventStore:ConnectionString"], Environment.ApplicationName); var store = new MeasuredStore( new AggregateStore(esConnection)); var customerService = new CustomerCommandService(store); var bus = MassTransitConfiguration.ConfigureBus( "rabbitmq://localhost", "guest", "guest", ("talk-customer", ep => { ep.Handler <Messages.Customer.Commands.RegisterCustomer>( ctx => customerService.Handle(ctx.Message)); })); services.AddMassTransit(bus); var reactorsSubscriptionManager = new SubscriptionManager( esConnection, new EsCheckpointStore(esConnection, "reactors-checkpoint"), "commandsReactors", ConfigureReactors() ); services.AddSingleton <IHostedService>( new EventStoreService( esConnection, reactorsSubscriptionManager) ); Log.SetLoggerFactory(LoggerFactory); services.AddSingleton <IHostedService>(provider => new ProtoClusterHostedService( new Uri(Configuration["Proto:ConsulUrl"]), Configuration["Proto:ClusterName"], "localhost", Configuration.GetValue <int>("Proto:NodePort"), esConnection)); }
public static MassTransitConfiguration GetMassTransitConfiguration(this IConfiguration configuration) { #warning можно так сделать, да, а можно ещё красивее /* * services.Configure<MassTransitConfiguration>(configuration.GetSection("MassTransit")); * services.AddSingleton<IMassTransitConfiguration>(isp => isp.GetRequiredService<IOptions<MassTransitConfiguration>>().Value); * */ #warning т.е. просто зарегать в DI IMassTransitConfiguration, и инжектить куда надо. #warning но, пожалуй, в этом случае это был бы оверинжиниринг var hostConfig = new MassTransitConfiguration(); configuration.GetSection(MassTransit).Bind(hostConfig); return(hostConfig); }