public RabbitMQConnection(
     ILogger <RabbitMQChannel> channelLogger,
     RabbitMQConnectionDeclaration connectionDeclaration,
     IConnection connection)
 {
     ConnectionDeclaration = connectionDeclaration;
     this.channelLogger    = channelLogger;
     this.connection       = connection;
 }
 public RabbitMQQueueDeclaration(
     RabbitMQConnectionDeclaration connectionDeclaration,
     string name)
 {
     ConnectionDeclaration = connectionDeclaration;
     Name                = name;
     Arguments           = new Dictionary <string, object>();
     BindingDeclarations = new List <RabbitMQQueueBindingDeclaration>();
 }
 public RabbitMQChannel(
     RabbitMQConnectionDeclaration connectionDeclaration,
     IFullModel channel,
     ILogger <RabbitMQChannel> logger)
 {
     this.logger           = logger;
     this.channel          = channel;
     ConnectionDeclaration = connectionDeclaration;
 }
예제 #4
0
 public RabbitMQProducerDeclaration(
     Type payloadType,
     RabbitMQConnectionDeclaration connectionDeclaration,
     RabbitMQExchangeDeclaration exchangeDeclaration)
 {
     PayloadType           = payloadType;
     ConnectionDeclaration = connectionDeclaration;
     ExchangeDeclaration   = exchangeDeclaration;
     Properties            = new List <Action <IBasicProperties> >();
     Arguments             = new Dictionary <string, object>();
 }
 public RabbitMQExchangeDeclaration(
     RabbitMQConnectionDeclaration connectionDeclaration,
     string type,
     string name)
 {
     ConnectionDeclaration = connectionDeclaration;
     Type                = type;
     Name                = name;
     Arguments           = new Dictionary <string, object>();
     BindingDeclarations = new List <RabbitMQExchangeBindingDeclaration>();
 }
예제 #6
0
 public RabbitMQConsumerDeclaration(
     Type payloadType,
     RabbitMQConnectionDeclaration connectionDeclaration,
     RabbitMQQueueDeclaration[] queueDeclarations)
 {
     PayloadType           = payloadType;
     ConnectionDeclaration = connectionDeclaration;
     QueueDeclarations     = queueDeclarations;
     Count         = 1;
     Arguments     = new Dictionary <string, object>();
     Subscriptions = new List <Func <IServiceScope, object, CancellationToken, ValueTask> >();
 }
예제 #7
0
        public static IRabbitMQBuilder AddConnection(
            this IRabbitMQBuilder builder,
            string name,
            Action <IRabbitMQConnectionBuilder> connection)
        {
            var declaration = new RabbitMQConnectionDeclaration(name);

            builder.Services
            .Configure <RabbitMQOptions>(options => options.ConnectionDeclarations.Add(declaration));

            connection.Invoke(new RabbitMQConnectionBuilder(builder.Services, declaration));

            return(builder);
        }
        public RabbitMQConnection FromDeclaration(RabbitMQConnectionDeclaration declaration)
        {
            return(connections.GetOrAdd(declaration.Name, _ =>
            {
                var connection = new RabbitMQConnection(
                    channelLogger,
                    declaration,
                    options.ConnectionFactory.ClientProvidedName is null
                                                ? options.ConnectionFactory.CreateConnection(declaration.Name)
                                                : options.ConnectionFactory.CreateConnection(
                        $"{options.ConnectionFactory.ClientProvidedName}.{declaration.Name}"));

                EnsureLogging(connection);

                return connection;
            }));
        }
 public RabbitMQConnectionBuilder(IServiceCollection services, RabbitMQConnectionDeclaration connectionDeclaration)
 {
     Services = services;
     ConnectionDeclaration = connectionDeclaration;
 }