public bool Matches(Uri address) { if (!address.Scheme.Equals("activemq", StringComparison.OrdinalIgnoreCase)) { return(false); } var settings = new ActiveMqHostConfigurator(address).Settings; return(ActiveMqHostEqualityComparer.Default.Equals(_settings, settings)); }
/// <summary> /// Configure a ActiveMQ host using the configuration API /// </summary> /// <param name="configurator"></param> /// <param name="hostAddress">The URI host address of the ActiveMQ host (activemq://host:port/vhost)</param> /// <param name="configure"></param> public static IActiveMqHost Host(this IActiveMqBusFactoryConfigurator configurator, Uri hostAddress, Action <IActiveMqHostConfigurator> configure) { if (hostAddress == null) { throw new ArgumentNullException(nameof(hostAddress)); } var hostConfigurator = new ActiveMqHostConfigurator(hostAddress); configure(hostConfigurator); return(configurator.Host(hostConfigurator.Settings)); }
/// <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="configuration">The <see cref="IConfiguration"/> being bound.</param> public ActiveMqHostBuilder(IServiceCollection services, string connectionName, IConfiguration configuration) : this(services, connectionName) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } services.AddOptions(); services.Configure <ActiveMqOptions>(ConnectionName, configuration); _hostConfiguratorFactory = serviceProvider => { var optionsSnapshot = serviceProvider.GetRequiredService <IOptionsSnapshot <ActiveMqOptions> >(); var options = optionsSnapshot.Get(ConnectionName); var hostConfigurator = new ActiveMqHostConfigurator(options.HostAddress); if (options.UseSsl) { hostConfigurator.UseSsl(); } if (!string.IsNullOrEmpty(options.Username)) { hostConfigurator.Username(options.Username); } if (!string.IsNullOrEmpty(options.Password)) { hostConfigurator.Password(options.Password); } return(hostConfigurator); }; }