@Override
 protected void onInit() {
   super.onInit();
   if (this.expectMessage) {
     Assert.notNull(
         this.serializer, "'serializer' has to be provided where 'expectMessage == true'.");
   }
   if (this.taskExecutor == null) {
     String beanName = this.getComponentName();
     this.taskExecutor =
         new SimpleAsyncTaskExecutor(
             (beanName == null ? "" : beanName + "-") + this.getComponentType());
   }
   if (!(this.taskExecutor instanceof ErrorHandlingTaskExecutor)
       && this.getBeanFactory() != null) {
     MessagePublishingErrorHandler errorHandler =
         new MessagePublishingErrorHandler(new BeanFactoryChannelResolver(this.getBeanFactory()));
     errorHandler.setDefaultErrorChannel(this.errorChannel);
     this.taskExecutor = new ErrorHandlingTaskExecutor(this.taskExecutor, errorHandler);
   }
 }
  @Override
  protected void onInit() {
    try {
      super.onInit();

      // regionService = this.region.getRegionService();
      queryService = this.pool.getQueryService();
      String defaultName =
          String.format("%s-%s-query", getComponentName() + "", getComponentType() + "");
      queryName = StringUtils.hasText(queryName) ? queryName : defaultName;
      this.cqQuery =
          registerContinuousQuery(
              queryService,
              queryName,
              this.queryString,
              this.durable,
              new MessageProducingCqListener());
    } catch (Throwable e) {
      throw new RuntimeException("Couldn't properly setup the " + getClass().getName(), e);
    }
  }
  @Override
  protected void onInit() {
    super.onInit();
    boolean hasTopics = false;
    if (this.topics != null) {
      Assert.noNullElements(this.topics, "'topics' may not contain null elements.");
      hasTopics = true;
    }
    boolean hasPatterns = false;
    if (this.topicPatterns != null) {
      Assert.noNullElements(this.topicPatterns, "'topicPatterns' may not contain null elements.");
      hasPatterns = true;
    }
    Assert.state(
        hasTopics || hasPatterns,
        "at least one topic or topic pattern is required for subscription.");

    if (this.messageConverter instanceof BeanFactoryAware) {
      ((BeanFactoryAware) this.messageConverter).setBeanFactory(this.getBeanFactory());
    }
    MessageListenerDelegate delegate = new MessageListenerDelegate();
    MessageListenerAdapter adapter = new MessageListenerAdapter(delegate);
    adapter.setSerializer(this.serializer);
    List<Topic> topicList = new ArrayList<Topic>();
    if (hasTopics) {
      for (String topic : this.topics) {
        topicList.add(new ChannelTopic(topic));
      }
    }
    if (hasPatterns) {
      for (String pattern : this.topicPatterns) {
        topicList.add(new PatternTopic(pattern));
      }
    }
    adapter.afterPropertiesSet();
    this.container.addMessageListener(adapter, topicList);
    this.container.afterPropertiesSet();
  }
 @Override
 protected void doStop() {
   super.doStop();
   this.container.stop();
 }
 @Override
 public void setErrorChannel(MessageChannel errorChannel) {
   super.setErrorChannel(errorChannel);
   this.errorChannel = errorChannel;
 }