@Override
  protected AbstractBeanDefinition doParse(
      Element element, ParserContext parserContext, String channelName) {
    if (parserContext.isNested()) {
      if (channelName != null) {
        String elementDescription = IntegrationNamespaceUtils.createElementDescription(element);
        parserContext
            .getReaderContext()
            .error(
                "The 'channel' attribute isn't allowed for "
                    + elementDescription
                    + " when it is used as a nested element,"
                    + " e.g. inside a <chain/>",
                element);
      }
      AbstractBeanDefinition consumerBeanDefinition = this.parseConsumer(element, parserContext);
      this.configureRequestHandlerAdviceChain(element, parserContext, consumerBeanDefinition, null);
      return consumerBeanDefinition;
    }
    BeanDefinitionBuilder builder =
        BeanDefinitionBuilder.genericBeanDefinition(ConsumerEndpointFactoryBean.class);
    Element pollerElement = DomUtils.getChildElementByTagName(element, "poller");
    BeanComponentDefinition handlerBeanComponentDefinition =
        this.doParseAndRegisterConsumer(element, parserContext);
    builder.addPropertyReference("handler", handlerBeanComponentDefinition.getBeanName());
    IntegrationNamespaceUtils.checkAndConfigureFixedSubscriberChannel(
        element, parserContext, channelName, handlerBeanComponentDefinition.getBeanName());
    if (pollerElement != null) {
      if (!StringUtils.hasText(channelName)) {
        parserContext
            .getReaderContext()
            .error(
                "outbound channel adapter with a 'poller' requires a 'channel' to poll", element);
      }
      IntegrationNamespaceUtils.configurePollerMetadata(pollerElement, builder, parserContext);
    }
    builder.addPropertyValue("inputChannelName", channelName);

    this.configureRequestHandlerAdviceChain(
        element, parserContext, handlerBeanComponentDefinition.getBeanDefinition(), builder);

    return builder.getBeanDefinition();
  }
 @Override
 protected AbstractBeanDefinition doParse(
     Element element, ParserContext parserContext, String channelName) {
   BeanMetadataElement source = this.parseSource(element, parserContext);
   if (source == null) {
     parserContext.getReaderContext().error("failed to parse source", element);
   }
   BeanDefinitionBuilder adapterBuilder =
       BeanDefinitionBuilder.genericBeanDefinition(SourcePollingChannelAdapterFactoryBean.class);
   adapterBuilder.addPropertyValue("source", source);
   adapterBuilder.addPropertyReference("outputChannel", channelName);
   IntegrationNamespaceUtils.setValueIfAttributeDefined(adapterBuilder, element, "send-timeout");
   Element pollerElement = DomUtils.getChildElementByTagName(element, "poller");
   if (pollerElement != null) {
     IntegrationNamespaceUtils.configurePollerMetadata(
         pollerElement, adapterBuilder, parserContext);
   }
   IntegrationNamespaceUtils.setValueIfAttributeDefined(adapterBuilder, element, "auto-startup");
   IntegrationNamespaceUtils.setValueIfAttributeDefined(adapterBuilder, element, "phase");
   return adapterBuilder.getBeanDefinition();
 }