private void InitializeEndpoint()
        {
            lock (_initializationMonitor) {
                if (_initialized)
                {
                    return;
                }

                AssertUtils.ArgumentHasText(_inputChannelName, "inputChannelName is required");

                AssertUtils.IsTrue(_objectFactory.ContainsObject(_inputChannelName), "no such input channel '" + _inputChannelName + "' for endpoint '" + _objectName + "'");

                IMessageChannel channel = (IMessageChannel)_objectFactory.GetObject(_inputChannelName, typeof(IMessageChannel));
                if (channel is ISubscribableChannel)
                {
                    if (_pollerMetadata != null)
                    {
                        throw new ArgumentException("A poller should not be specified for endpoint '" + _objectName
                                                    + "', since '" + _inputChannelName + "' is a SubscribableChannel (not pollable).");
                    }
                    _endpoint = new EventDrivenConsumer((ISubscribableChannel)channel, _handler);
                }
                else if (channel is IPollableChannel)
                {
                    PollingConsumer pollingConsumer = new PollingConsumer((IPollableChannel)channel, _handler);
                    if (_pollerMetadata == null)
                    {
                        _pollerMetadata = IntegrationContextUtils.GetDefaultPollerMetadata(_objectFactory);
                        AssertUtils.ArgumentNotNull(_pollerMetadata, "No poller has been defined for endpoint '" + _objectName + "', and no default poller is available within the context.");
                    }
                    pollingConsumer.Trigger               = _pollerMetadata.Trigger;
                    pollingConsumer.MaxMessagesPerPoll    = _pollerMetadata.MaxMessagesPerPoll;
                    pollingConsumer.ReceiveTimeout        = _pollerMetadata.ReceiveTimeout;
                    pollingConsumer.TaskExecutor          = _pollerMetadata.TaskExecutor;
                    pollingConsumer.TransactionManager    = _pollerMetadata.TransactionManager;
                    pollingConsumer.TransactionDefinition = _pollerMetadata.TransactionDefinition;
                    pollingConsumer.AdviceChain           = _pollerMetadata.AdviceChain;
                    _endpoint = pollingConsumer;
                }
                else
                {
                    throw new ArgumentException("unsupported channel type: [" + channel.GetType() + "]");
                }
                _endpoint.AutoStartup   = _autoStartup;
                _endpoint.ObjectName    = _objectName;
                _endpoint.ObjectFactory = _objectFactory;
                _endpoint.AfterPropertiesSet();
                _initialized = true;
            }
        }