104.21. 동일한 파일을 두 번 이상 읽지 않도록 (idempotent 소비자)


Camel은 구성 요소 내에서 직접 Idempotent Consumer를 지원하므로 이미 처리된 파일을 건너뜁니다. 이 기능은 idempotent=true 옵션을 설정하여 활성화할 수 있습니다.

from("file://inbox?idempotent=true").to("...");
Copy to Clipboard Toggle word wrap

Camel은 절대 파일 이름을 idempotent 키로 사용하여 중복 파일을 감지합니다. Camel 2.11 이상에서 idempotentKey 옵션의 표현식을 사용하여 이 키를 사용자 지정할 수 있습니다. 예를 들어 이름과 파일 크기를 키로 사용하려면 다음을 수행합니다.

<route>
  <from uri="file://inbox?idempotent=true&amp;idempotentKey=${file:name}-${file:size}"/>
  <to uri="bean:processInbox"/>
</route>
Copy to Clipboard Toggle word wrap

기본적으로 Camel은 사용된 파일을 추적하기 위해 메모리 기반 저장소에 를 사용하며, 최근 사용된 캐시는 최대 1000개의 항목을 유지합니다. 값이 # Sign을 사용하여 idempotentRepository 옵션을 사용하여 지정된 idempotentRepository가 있는 레지스트리의 8080을 참조하여 이 저장소를 직접 구현할 수 있습니다.

 <!-- define our store as a plain spring bean -->
 <bean id="myStore" class="com.mycompany.MyIdempotentStore"/>

<route>
  <from uri="file://inbox?idempotent=true&amp;idempotentRepository=#myStore"/>
  <to uri="bean:processInbox"/>
</route>
Copy to Clipboard Toggle word wrap

Camel은 이전에 사용되었기 때문에 파일을 건너뛰는 경우 DEBUG 수준에서 로그됩니다.

DEBUG FileConsumer is idempotent and the file has been consumed before. Will skip this file: target\idempotent\report.txt
Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat