public HandlerTests()
        {
            repository = new InMemoryRepository();
            var actUpdater   = new ActUpdater(repository);
            var venueUpdater = new VenueUpdater(repository);

            showAddedHandler               = new ShowAddedHandler(repository, actUpdater, venueUpdater);
            actDescriptionChangedHandler   = new ActDescriptionChangedHandler(repository, actUpdater);
            venueDescriptionChangedHandler = new VenueDescriptionChangedHandler(repository, venueUpdater);
            venueLocationChangedHandler    = new VenueLocationChangedHandler(repository, venueUpdater);
        }
Example #2
0
        static async Task Main(string[] args)
        {
            var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
                           .DefaultMappingFor <ShowDocument>(m => m
                                                             .IndexName("shows")
                                                             )
                           .DefaultMappingFor <ActDocument>(m => m
                                                            .IndexName("acts")
                                                            )
                           .DefaultMappingFor <VenueDocument>(m => m
                                                              .IndexName("venues")
                                                              );
            var elasticClient           = new ElasticClient(settings);
            var elasticsearchRepository = new ElasticsearchRepository(elasticClient);
            var actUpdater                     = new ActUpdater(elasticsearchRepository);
            var venueUpdater                   = new VenueUpdater(elasticsearchRepository);
            var showAddedHandler               = new ShowAddedHandler(elasticsearchRepository, actUpdater, venueUpdater);
            var actDescriptionChangedHandler   = new ActDescriptionChangedHandler(elasticsearchRepository, actUpdater);
            var venueDescriptionChangedHandler = new VenueDescriptionChangedHandler(elasticsearchRepository, venueUpdater);
            var venueLocationChangedHandler    = new VenueLocationChangedHandler(elasticsearchRepository, venueUpdater);

            var bus = Bus.Factory.CreateUsingRabbitMq(busConfig =>
            {
                busConfig.Host("rabbitmq://localhost");
                busConfig.ReceiveEndpoint("GloboTicket.Indexer", endpointConfig =>
                {
                    endpointConfig.UseMessageRetry(r => r.Exponential(
                                                       retryLimit: 5,
                                                       minInterval: TimeSpan.FromSeconds(5),
                                                       maxInterval: TimeSpan.FromSeconds(30),
                                                       intervalDelta: TimeSpan.FromSeconds(5)));

                    endpointConfig.Handler <ShowAdded>(async context =>
                                                       await showAddedHandler.Handle(context.Message));
                    endpointConfig.Handler <ActDescriptionChanged>(async context =>
                                                                   await actDescriptionChangedHandler.Handle(context.Message));
                    endpointConfig.Handler <VenueDescriptionChanged>(async context =>
                                                                     await venueDescriptionChangedHandler.Handle(context.Message));
                    endpointConfig.Handler <VenueLocationChanged>(async context =>
                                                                  await venueLocationChangedHandler.Handle(context.Message));
                });
            });

            await bus.StartAsync();

            Console.WriteLine("Receiving messages. Press a key to stop.");
            await Task.Run(() => Console.ReadKey());

            await bus.StopAsync();
        }