public void RegisterEndpoint(IRabbitListenerEndpoint endpoint, IRabbitListenerContainerFactory factory)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }

            if (string.IsNullOrEmpty(endpoint.Id))
            {
                throw new InvalidOperationException("Endpoint id must be set");
            }

            if (StartImmediately && EndpointRegistry == null)
            {
                throw new InvalidOperationException("No registry available");
            }

            // Factory may be null, we defer the resolution right before actually creating the container
            var descriptor = new AmqpListenerEndpointDescriptor(endpoint, factory);

            lock (_endpointDescriptors)
            {
                if (StartImmediately)
                { // Register and start immediately
                    EndpointRegistry.RegisterListenerContainer(descriptor.Endpoint, ResolveContainerFactory(descriptor), true);
                }
                else
                {
                    _endpointDescriptors.Add(descriptor);
                }
            }
        }
        protected void RegisterAllEndpoints()
        {
            if (EndpointRegistry == null)
            {
                throw new InvalidOperationException("No registry available");
            }

            lock (_endpointDescriptors)
            {
                foreach (var descriptor in _endpointDescriptors)
                {
                    EndpointRegistry.RegisterListenerContainer(descriptor.Endpoint, ResolveContainerFactory(descriptor));
                }

                StartImmediately = true;  // trigger immediate startup
            }
        }