문제

파일의 디렉토리를 폴링하려면 Spring Integration을 사용하여 서비스 클래스 에서이 파일을 처리 하고이 파일을 출력 디렉토리에 써서 원래 파일을 삭제합니다.

다음과 같은 XML 구성이 있습니다.

  <int-file:inbound-channel-adapter id="filesInChannel"
                                    directory="file:${java.io.tmpdir}/input" 
                                    auto-create-directory="true"  >
      <int:poller id="poller" fixed-delay="1000" />
  </int-file:inbound-channel-adapter>

  <int:service-activator id="servicActivator"
                         input-channel="filesInChannel"
                         output-channel="filesOut"
                         ref="my_file_processing_service">
  </int:service-activator>

  <int-file:outbound-channel-adapter  id="filesOut" auto-create-directory="true" delete-source-files="true" directory="file:${java.io.tmpdir}/output"/>
.

파일을 폴링하고이를 My Processing_Service로 전달하여 아웃 바운드 디렉토리에 복사합니다.그러나 원래 파일은 삭제되지 않습니다.누구도 어떤 아이디어가 있는지 아닌가?

도움이 되었습니까?

해결책

나는 그 질문이 오래 전에 물어 봤지만 대답은 다른 사람에게 유용 할 것입니다.

입력 파일이 삭제되지 않은 이유는 Spring Integration Reference :

delete-source-files 속성은 인바운드 메시지에는 파일 페이로드 또는 FileHeaders.ORIGINAL_FILE가있는 경우 헤더 값은 소스 파일 인스턴스 또는 문자열을 포함합니다. 원래 파일 경로를 나타내는

메시지에는이 특정 헤더가 없습니다. 표준 파일 중 하나를 사용하는 경우 변압기 (FileToStringTransformerFileToByteArrayTransformer) 자동으로 설정됩니다. 또는 수동으로 수동으로 설정할 수 있습니다. 헤더 Enricher .

이와 같은 뒤에 파일 변압기에서 일어나고있는 것 :

...
Message<?> transformedMessage = MessageBuilder.withPayload(result)
        .copyHeaders(message.getHeaders())
        .setHeaderIfAbsent(FileHeaders.ORIGINAL_FILE, file)
        .setHeaderIfAbsent(FileHeaders.FILENAME, file.getName())
        .build();
...
.

다른 팁

문서에서 http://static.springsource.org/spring- integration / reference / html / files.html

<int-file:outbound-gateway id="mover" request-channel="moveInput"
reply-channel="output"
directory="${output.directory}"
mode="REPLACE" delete-source-files="true"/>
.

인바운드 채널 어댑터 (내가 생각하는 것라고 생각하는 것) 에서이 작업을 수행하는 방법을 모르겠습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top