Exemplo n.º 1
0
 @Override
 protected void doStart() throws Exception {
   // turn off scheduler first, so autoCreate is handled before scheduler starts
   boolean startScheduler = isStartScheduler();
   setStartScheduler(false);
   try {
     super.doStart();
     if (endpoint.isAutoCreate()) {
       log.debug("Auto creating directory: {}", endpoint.getConfiguration().getDirectory());
       try {
         connectIfNecessary();
         operations.buildDirectory(endpoint.getConfiguration().getDirectory(), true);
       } catch (GenericFileOperationFailedException e) {
         // log a WARN as we want to start the consumer.
         log.warn(
             "Error auto creating directory: "
                 + endpoint.getConfiguration().getDirectory()
                 + " due "
                 + e.getMessage()
                 + ". This exception is ignored.",
             e);
       }
     }
   } finally {
     if (startScheduler) {
       setStartScheduler(true);
       startScheduler();
     }
   }
 }
Exemplo n.º 2
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;
  }