예제 #1
0
        public void SetUp()
        {
            _semaphore = new Semaphore(0, 1);
            _consumer  = new Consumer <TestMessage>(_semaphore);
            IConsumer[] consumers = { _consumer };

            var rabbitMqHostConfiguration = CreateRabbitMqHostConfiguration();

            var rabbitMqMessageBusFactory = new RabbitMqMessageBusFactory(
                rabbitMqHostConfiguration,
                new RabbitMqReceiveEndpointConfigurator(
                    new ConsumerRegistrar(
                        new PreviouslyConstructedConsumerFactory(consumers),
                        new ConsumerTypeProvider(typeof(Consumer <TestMessage>)),
                        new ReceiveEndpointConfiguration(QueueName)
                        )
                    )
                );

            _busControl = new MultipleConnectionAttemptMessageBusFactory(rabbitMqMessageBusFactory, CreateRabbitMqHostConfiguration()).Create();
            _rabbitMqSendEndpointProvider = new RabbitMqSendEndpointProvider(_busControl, rabbitMqHostConfiguration);
        }
예제 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var menuConfiguration = new MenuConfiguration(Configuration);

            services.Add(new ServiceDescriptor(typeof(IMenuConfiguration), menuConfiguration));
            var connectionString = GetConnectionString();

            services.Add(new ServiceDescriptor(typeof(IMenuRepository), new MenuRepository(menuConfiguration, connectionString)));
            services.Add(new ServiceDescriptor(typeof(ITabDetailsRepository), new TabDetailsRepository(connectionString)));
            services.Add(new ServiceDescriptor(typeof(IOpenTabsRepository), new OpenTabsRepository(connectionString)));
            services.Add(new ServiceDescriptor(typeof(IPlaceOrderCommandFactory), typeof(PlaceOrderCommandFactory), ServiceLifetime.Transient));
            services.Add(new ServiceDescriptor(typeof(ICommandSender), typeof(CommandSender), ServiceLifetime.Transient));
            services.Add(new ServiceDescriptor(typeof(ISendEndpointProvider), typeof(RabbitMqSendEndpointProvider), ServiceLifetime.Transient));
            var rabbitMqMessageBusFactory = new RabbitMqMessageBusFactory(new RabbitMqHostConfiguration(Configuration), NoReceiveEndpointsConfigurator.Instance);

            services.Add(new ServiceDescriptor(typeof(IBusControl), rabbitMqMessageBusFactory.Create()));
            services.Add(new ServiceDescriptor(typeof(IRabbitMqHostConfiguration), new RabbitMqHostConfiguration(Configuration)));
            services.AddSingleton(typeof(IConfigurationRoot), Configuration);
            services.Add(new ServiceDescriptor(typeof(ICommandSendConfiguration), typeof(CommandSendConfiguration), ServiceLifetime.Transient));

            // Add framework services.
            services.AddMvc();
        }