예제 #1
0
        /// <summary>
        /// Configures a RabbitMQ bus by using the specified application configuration.
        /// </summary>
        /// <param name="builder"><see cref="IMassTransitBuilder"/></param>.
        /// <param name="configuration">The <see cref="IConfiguration"/> being bound.</param>
        /// <param name="hostConfigurator">The configuration callback to configure the RabbitMQ bus.</param>
        public static void UseRabbitMq(this IMassTransitBuilder builder, IConfiguration configuration, Action <IRabbitMqHostBuilder> hostConfigurator = null)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var connectionName = configuration["ConnectionName"];
            var hostBuilder    = new RabbitMqHostBuilder(builder.Services, connectionName, configuration);

            hostConfigurator?.Invoke(hostBuilder);
        }
        /// <summary>
        /// Configures a RabbitMq bus.
        /// </summary>
        /// <param name="builder"><see cref="IMassTransitBuilder"/></param>
        /// <param name="hostAddress">The URI host address of the RabbitMQ host (example: rabbitmq://host:port/vhost).</param>
        /// <param name="connectionName">The client-provided connection name.</param>
        /// <param name="hostConfigurator">The configuration callback to configure the RabbitMq bus.</param>
        public static void UseRabbitMq(this IMassTransitBuilder builder, Uri hostAddress, string connectionName, Action <IRabbitMqHostBuilder> hostConfigurator)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (hostAddress == null)
            {
                throw new ArgumentNullException(nameof(hostAddress));
            }

            var hostBuilder = new RabbitMqHostBuilder(builder.Services, hostAddress, connectionName);

            hostConfigurator?.Invoke(hostBuilder);
        }
        /// <summary>
        /// Configures a RabbitMq bus by using the specified settings.
        /// </summary>
        /// <param name="builder"><see cref="IMassTransitBuilder"/></param>.
        /// <param name="host">The host name of the RabbitMq broker.</param>
        /// <param name="port">The port to connect to on the RabbitMq broker.</param>
        /// <param name="virtualHost">The virtual host to use.</param>
        /// <param name="connectionName">The client-provided connection name.</param>
        /// <param name="hostConfigurator">The configuration callback to configure the RabbitMq bus.</param>
        public static void UseRabbitMq(this IMassTransitBuilder builder, string host, ushort port, string virtualHost, string connectionName, Action <IRabbitMqHostBuilder> hostConfigurator)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }
            if (virtualHost == null)
            {
                throw new ArgumentNullException(nameof(virtualHost));
            }

            var hostBuilder = new RabbitMqHostBuilder(builder.Services, host, port, virtualHost, connectionName);

            hostConfigurator?.Invoke(hostBuilder);
        }