Пример #1
0
        /// <summary>
        /// Registers a receiver using the <paramref name="configuration"/>
        /// </summary>
        /// <param name="configuration">
        /// Receiver configuration
        /// </param>
        /// <param name="isCallback">
        /// Denotes if a receiver should handle the callback messages
        /// </param>
        /// <returns>
        /// The <see cref="RabbitReceiver"/>.
        /// </returns>
        public RabbitReceiver RegisterReceiver(IReceiverConfiguration configuration, bool isCallback = false)
        {
            this.logger.Trace(
                $"Registering a new receiver of [{configuration.Label}] with connection string [{configuration.Options.GetConnectionString()}]");

            RabbitReceiver receiver;

            if (isCallback)
            {
                receiver = new RabbitCallbackReceiver(this, configuration, this.connectionPool);

                // No need to subscribe to listener-created event as it will not be fired by the callback receiver. A callback listener is not checked with listeners in other receivers for compatibility.
            }
            else
            {
                receiver = new RabbitReceiver(this, configuration, this.connectionPool);
                receiver.ListenerCreated += this.OnListenerCreated;
            }

            this.ComponentTracker.Register(receiver);

            this.logger.Trace(
                $"A receiver of [{configuration.Label}] with connection string [{configuration.Options.GetConnectionString()}] registered successfully");
            return(receiver);
        }
Пример #2
0
        /// <summary>
        /// The build receivers.
        /// </summary>
        private void BuildReceivers()
        {
            this.ListenerRegistry = new ListenerRegistry(this);

            this.Configuration.ReceiverConfigurations.ForEach(
                c =>
            {
                var receiver = new RabbitReceiver(c, this.ListenerRegistry);
                this.ComponentTracker.Register(receiver);
            });
        }
Пример #3
0
        /// <summary>
        /// Registers a receiver using the <paramref name="configuration"/>
        /// </summary>
        /// <param name="configuration">
        /// Receiver configuration
        /// </param>
        /// <returns>
        /// The <see cref="RabbitReceiver"/>.
        /// </returns>
        public RabbitReceiver RegisterReceiver(IReceiverConfiguration configuration)
        {
            this.logger.Trace(
                $"Registering a new receiver of [{configuration.Label}] with connection string [{configuration.Options.GetConnectionString()}]");

            var receiver = new RabbitReceiver(this, configuration, this.connectionPool);

            receiver.ListenerRegistered += this.OnListenerRegistered;
            this.ComponentTracker.Register(receiver);

            this.logger.Trace(
                $"A receiver of [{configuration.Label}] with connection string [{configuration.Options.GetConnectionString()}] registered successfully");
            return(receiver);
        }