예제 #1
0
 internal void RemoveSubscription(RabbitMQSubscription item)
 {
     lock (subscriptions)
     {
         subscriptions.Remove(item);
     }
 }
예제 #2
0
        /// <summary>
        /// Creates a new instance of <see cref="RabbitMQSubscription"/>.
        /// </summary>
        /// <returns>Instance of <see cref="RabbitMQSubscription"/> ready to start
        /// consuming messages.</returns>
        /// <inheritdoc/>
        public ISubscription Subscribe(Action <byte[], IMessageContext> handler, params string[] queues)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(nameof(RabbitMQMessaging));
            }

            var(channel, channelEvents) = CreateChannel();

            var subscription = new RabbitMQSubscription(channel, channelEvents, handler,
                                                        configuration, this, loggerFactory, queues);

            subscriptions.Add(subscription);

            logger.LogInformation($"{nameof(Subscribe)}: Subscription created");

            return(subscription);
        }