Ejemplo n.º 1
0
        private static RabbitMqOptionsBuilder BuildInternal(StandardConfigurer <ITransport> configurer, bool oneway, Func <IResolutionContext, RabbitMqOptionsBuilder, RabbitMqTransport> rabbitMqTransportBuilder)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }

            var options = new RabbitMqOptionsBuilder();

            configurer
            .OtherService <RabbitMqTransport>()
            .Register(c =>
            {
                var transport = rabbitMqTransportBuilder(c, options);
                options.Configure(transport);
                return(transport);
            });

            configurer
            .OtherService <ISubscriptionStorage>()
            .Register(c => c.Get <RabbitMqTransport>(), description: RabbitMqSubText);

            configurer.Register(c => c.Get <RabbitMqTransport>());

            if (oneway)
            {
                OneWayClientBackdoor.ConfigureOneWayClient(configurer);
            }
            return(options);
        }
        /// <summary>
        /// Configures Rebus to use RabbitMQ to move messages around
        /// </summary>
        public static RabbitMqOptionsBuilder UseRabbitMq(this StandardConfigurer <ITransport> configurer, string connectionString, string inputQueueName)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }
            if (connectionString == null)
            {
                throw new ArgumentNullException(nameof(connectionString));
            }
            if (inputQueueName == null)
            {
                throw new ArgumentNullException(nameof(inputQueueName));
            }

            var options = new RabbitMqOptionsBuilder();

            configurer
            .OtherService <RabbitMqTransport>()
            .Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var transport          = new RabbitMqTransport(connectionString, inputQueueName, rebusLoggerFactory);
                options.Configure(transport);
                return(transport);
            });

            configurer
            .OtherService <ISubscriptionStorage>()
            .Register(c => c.Get <RabbitMqTransport>(), description: RabbitMqSubText);

            configurer.Register(c => c.Get <RabbitMqTransport>());

            return(options);
        }