Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RabbitMQConnector" /> class.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="virtualHost">The virtual host.</param>
        /// <param name="defaultExchange">The default exchange.</param>
        /// <exception cref="ArgumentNullException">connection</exception>
        /// <exception cref="ArgumentNullException">defaultExchange</exception>
        public RabbitMQConnector(IConnection connection, string virtualHost, string defaultExchange)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            ConnectionFactory = new ConnectionFactory {
                HostName = connection.Host, Port = connection.Port
            };

            if (!string.IsNullOrWhiteSpace(connection.Credentials?.UserName))
            {
                ConnectionFactory.UserName = connection.Credentials.UserName;
            }

            if (!string.IsNullOrWhiteSpace(connection.Credentials?.Password))
            {
                ConnectionFactory.Password = connection.Credentials.Password;
            }

            ConnectionFactory.VirtualHost = virtualHost ?? throw new ArgumentNullException(nameof(defaultExchange));

            DefaultExchangeName = defaultExchange;
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RabbitMQConnector" /> class.
 /// </summary>
 /// <param name="connection">The connection.</param>
 public RabbitMQConnector(IConnection connection)
     : this(connection, "/", $"{EnvironmentHelper.ApplicationName}.logs")
 {
 }