78.3. 마침 안 됨
이 예제에서는 MY_QUEUE라는 ActiveMQ 대기열에서 Zip 파일 페이로드를 원래 형식으로 분리하고 처리를 위해 UnZippedMessageProcessor
로 전달합니다.
from("activemq:queue:MY_QUEUE") .unmarshal().zipFile() .process(new UnZippedMessageProcessor());
from("activemq:queue:MY_QUEUE")
.unmarshal().zipFile()
.process(new UnZippedMessageProcessor());
zip 파일에 하나 이상의 항목이 있는 경우 ZipFileDataFormat의 usingIterator 옵션을 true로 지정하고 splitter를 사용하여 추가 작업을 수행할 수 있습니다.
또는 Zip>-<ter를 다음과 같이 스플릿터의 표현식으로 사용할 수 있습니다.
from("file:src/test/resources/org/apache/camel/dataformat/zipfile?delay=1000&noop=true") .split(new ZipSplitter()).streaming() .process(new UnZippedMessageProcessor()) .end();
from("file:src/test/resources/org/apache/camel/dataformat/zipfile?delay=1000&noop=true")
.split(new ZipSplitter()).streaming()
.process(new UnZippedMessageProcessor())
.end();
78.3.1. 집계 링크 복사링크가 클립보드에 복사되었습니다!
이 집계 전략을 사용하려면 빠른 완료 검사가 제대로 작동해야 합니다.
이 예제에서는 입력 디렉터리에 있는 모든 텍스트 파일을 출력 디렉터리에 저장된 단일 Zip 파일로 집계합니다.
from("file:input/directory?antInclude=*/.txt") .aggregate(constant(true), new ZipAggregationStrategy()) .completionFromBatchConsumer().eagerCheckCompletion() .to("file:output/directory");
from("file:input/directory?antInclude=*/.txt")
.aggregate(constant(true), new ZipAggregationStrategy())
.completionFromBatchConsumer().eagerCheckCompletion()
.to("file:output/directory");
발신 CamelFileName
메시지 헤더는 java.io.File.createTempFile을 ".zip" 접미사로 사용하여 생성됩니다. 이 동작을 재정의하려면 경로에서 명시적으로 CamelFileName
헤더 값을 설정할 수 있습니다.
from("file:input/directory?antInclude=*/.txt") .aggregate(constant(true), new ZipAggregationStrategy()) .completionFromBatchConsumer().eagerCheckCompletion() .setHeader(Exchange.FILE_NAME, constant("reports.zip")) .to("file:output/directory");
from("file:input/directory?antInclude=*/.txt")
.aggregate(constant(true), new ZipAggregationStrategy())
.completionFromBatchConsumer().eagerCheckCompletion()
.setHeader(Exchange.FILE_NAME, constant("reports.zip"))
.to("file:output/directory");