Пример #1
0
        public RabbitMqEventSubscription(string exchange,
                                         string exchangeType,
                                         Func <IRabbitMqQueueMessage, Task> onMessage,
                                         string queueName = "",
                                         Expression <Func <TEvent, bool> >?routingStrategy = null,
                                         bool isExchangeDurable                  = true,
                                         bool isExchangeAutoDelete               = true,
                                         bool createExchangeIfNotExist           = true,
                                         bool createDeadLetterExchangeIfNotExist = true,
                                         bool isQueueDurable    = false,
                                         bool isQueueAutoAck    = false,
                                         bool isQueueAutoDelete = true,
                                         bool isQueueExclusive  = true)
        {
            RabbitMqQueueConfiguration = new RabbitMqQueueConfiguration <TEvent>(routingStrategy,
                                                                                 queueName: queueName,
                                                                                 isDurable: isQueueDurable,
                                                                                 isExclusive: isQueueExclusive,
                                                                                 isAutoDelete: isQueueAutoDelete,
                                                                                 isAutoAck: isQueueAutoAck);

            RabbitMqExchangeConfiguration = new RabbitMqExchangeConfiguration(exchange,
                                                                              exchangeType,
                                                                              createExchangeIfNotExist: createExchangeIfNotExist,
                                                                              createDeadLetterExchangeIfNotExist: createDeadLetterExchangeIfNotExist,
                                                                              isAutoDelete: isExchangeAutoDelete,
                                                                              isDurable: isExchangeDurable
                                                                              );

            OnMessage = onMessage;

            SubscriptionId = $"{RabbitMqExchangeConfiguration.ExchangeName}-{RabbitMqQueueConfiguration.RoutingKey}";
        }
Пример #2
0
        public RabbitMqEventSubscription(Func <IRabbitMqQueueMessage, Task> onMessage,
                                         IRabbitMqQueueConfiguration rabbitMqQueueConfiguration,
                                         IRabbitMqExchangeConfiguration rabbitMqExchangeConfiguration)
        {
            RabbitMqQueueConfiguration    = rabbitMqQueueConfiguration;
            RabbitMqExchangeConfiguration = rabbitMqExchangeConfiguration;
            OnMessage = onMessage;

            SubscriptionId = $"{RabbitMqExchangeConfiguration.ExchangeName}-{RabbitMqQueueConfiguration.RoutingKey}";
        }