public ChannelFactory(IConnectionFactory connectionFactory, ZyRabbitConfiguration config, ILogger <ChannelFactory> logger) { ConnectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); ClientConfig = config ?? throw new ArgumentNullException(nameof(config)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); Channels = new ConcurrentBag <IModel>(); }
public ChannelFactory(IConnectionFactory connectionFactory, ZyRabbitConfiguration config, ILogger <Channel.ChannelFactory> logger, ConnectionPolicies policies = null) : base(connectionFactory, config, logger) { CreateChannelPolicy = policies?.CreateChannel ?? Policy.NoOpAsync(); ConnectPolicy = policies?.Connect ?? Policy.NoOpAsync(); GetConnectionPolicy = policies?.GetConnection ?? Policy.NoOpAsync(); }
public static ZyRabbitConfiguration Parse(string connectionString) { var mainMatch = MainRegex.Match(connectionString); var port = Defaults.Port; if (RegexMatchGroupIsNonEmpty(mainMatch, "port")) { var suppliedPort = mainMatch.Groups["port"].Value; if (!int.TryParse(suppliedPort, out port)) { throw new FormatException($"The supplied port '{suppliedPort}' in the connection string is not a number"); } } var cfg = new ZyRabbitConfiguration { Username = RegexMatchGroupIsNonEmpty(mainMatch, "username") ? mainMatch.Groups["username"].Value : Defaults.Username, Password = RegexMatchGroupIsNonEmpty(mainMatch, "password") ? mainMatch.Groups["password"].Value : Defaults.Password, Hostnames = mainMatch.Groups["hosts"].Value.Split(',').ToList(), Port = port, VirtualHost = ExctractVirutalHost(mainMatch) }; var parametersMatches = ParametersRegex.Matches(mainMatch.Groups["parameters"].Value); foreach (Match match in parametersMatches) { var name = match.Groups["name"].Value.ToLower(); var val = match.Groups["value"].Value.ToLower(); var propertyInfo = cfg .GetType() .GetTypeInfo() .GetProperty(name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance); if (propertyInfo == null) { throw new ArgumentException($"No configuration property named '{name}'"); } if (propertyInfo.PropertyType == typeof(TimeSpan)) { var convertedValue = TimeSpan.FromSeconds(int.Parse(val)); propertyInfo.SetValue(cfg, convertedValue, null); } else { propertyInfo.SetValue(cfg, Convert.ChangeType(val, propertyInfo.PropertyType), null); } } return(cfg); }
public ResourceDisposer( IChannelFactory channelFactory, IConnectionFactory connectionFactory, ISubscriptionRepository subscriptionRepo, IChannelPoolFactory channelPoolFactory, ZyRabbitConfiguration config) { _channelFactory = channelFactory; _connectionFactory = connectionFactory; _subscriptionRepo = subscriptionRepo; _channelPoolFactory = channelPoolFactory; _config = config; }
public MessageSequence(IBusClient client, INamingConventions naming, ZyRabbitConfiguration clientCfg, ILogger <MessageSequence> logger, SequenceModel model = null) : base(model) { _client = client ?? throw new ArgumentNullException(nameof(client)); _naming = naming ?? throw new ArgumentNullException(nameof(naming)); _clientCfg = clientCfg ?? throw new ArgumentNullException(nameof(clientCfg)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _triggerConfigurer = new TriggerConfigurer(); _stepDefinitions = new Queue <StepDefinition>(); _subscriptions = new List <Subscription.ISubscription>(); }
public IDictionary <string, object> GetClientProperties(ZyRabbitConfiguration cfg = null) { var props = new Dictionary <string, object> { { "product", "ZyRabbit" }, { "version", typeof(IBusClient).GetTypeInfo().Assembly.GetName().Version.ToString() }, { "platform", ".NET" }, { "client_directory", typeof(IBusClient).GetTypeInfo().Assembly.CodeBase }, { "client_server", Environment.MachineName }, }; if (cfg != null) { props.Add("request_timeout", cfg.RequestTimeout.ToString("g")); props.Add("broker_username", cfg.Username); } return(props); }
public QueueDeclarationFactory(ZyRabbitConfiguration config, INamingConventions conventions) { _config = config; _conventions = conventions; }
public PipeContextFactory(ZyRabbitConfiguration config) { _config = config; }
public BasicPublishConfigurationFactory(INamingConventions conventions, ISerializer serializer, ZyRabbitConfiguration config) { _conventions = conventions; _serializer = serializer; _config = config; }