/// <summary> /// Configures a ActiveMQ bus by using the specified <paramref name="options"/>. /// </summary> /// <param name="builder"><see cref="IMassTransitBuilder"/></param>. /// <param name="options"><see cref="ActiveMqOptions"/></param> /// <param name="hostConfigurator">The configuration callback to configure the ActiveMQ bus.</param> public static void UseActiveMq(this IMassTransitBuilder builder, ActiveMqOptions options, Action <IActiveMqHostBuilder> hostConfigurator = null) { if (options == null) { throw new ArgumentNullException(nameof(options)); } UseActiveMq(builder, options.ConnectionName, options.Host, options.Port, hostBuilder => { if (options.UseSsl) { hostBuilder.UseSsl(); } if (!string.IsNullOrEmpty(options.Username)) { hostBuilder.UseUsername(options.Username); } if (!string.IsNullOrEmpty(options.Password)) { hostBuilder.UsePassword(options.Password); } hostConfigurator?.Invoke(hostBuilder); }); }
/// <summary> /// Initializes a new instance of the <see cref="ActiveMqHostBuilder"/> class. /// </summary> /// <param name="services"><see cref="IServiceCollection"/></param> /// <param name="connectionName">The client-provided connection name.</param> /// <param name="host">The host name of the ActiveMQ broker.</param> /// <param name="port">The port to connect to on the ActiveMQ broker.</param> public ActiveMqHostBuilder(IServiceCollection services, string connectionName, string host, int?port = null) : this(services, connectionName) { if (host == null) { throw new ArgumentNullException(nameof(host)); } var hostAddress = ActiveMqOptions.FormatHostAddress(host, port, false); _hostConfiguratorFactory = serviceProvider => new ActiveMqHostConfigurator(hostAddress); }