Example #1
0
  @Override
  public RemoteFileConsumer<T> createConsumer(Processor processor) throws Exception {
    afterPropertiesSet();
    RemoteFileConsumer<T> consumer = buildConsumer(processor);

    if (isDelete() && getMove() != null) {
      throw new IllegalArgumentException("You cannot both set delete=true and move options");
    }

    // if noop=true then idempotent should also be configured
    if (isNoop() && !isIdempotentSet()) {
      log.info(
          "Endpoint is configured with noop=true so forcing endpoint to be idempotent as well");
      setIdempotent(true);
    }

    // if idempotent and no repository set then create a default one
    if (isIdempotentSet() && isIdempotent() && idempotentRepository == null) {
      log.info(
          "Using default memory based idempotent repository with cache max size: "
              + DEFAULT_IDEMPOTENT_CACHE_SIZE);
      idempotentRepository =
          MemoryIdempotentRepository.memoryIdempotentRepository(DEFAULT_IDEMPOTENT_CACHE_SIZE);
    }

    if (!getConfiguration().isUseList() && getFileName() == null) {
      throw new IllegalArgumentException(
          "Endpoint is configured with useList=false, then fileName must be configured also");
    }

    // set max messages per poll
    consumer.setMaxMessagesPerPoll(getMaxMessagesPerPoll());
    consumer.setEagerLimitMaxMessagesPerPoll(isEagerMaxMessagesPerPoll());

    configureConsumer(consumer);
    return consumer;
  }