다음 샘플에서는 direct:in 끝점에서 System.out 스트림으로 메시지를 라우팅합니다.
// Route messages to the standard output.
from("direct:in").to("stream:out");
// Send String payload to the standard output.
// Message will be followed by the newline.
template.sendBody("direct:in", "Hello Text World");
// Send byte[] payload to the standard output.
// No newline will be added after the message.
template.sendBody("direct:in", "Hello Bytes World".getBytes());
// Route messages to the standard output.
from("direct:in").to("stream:out");
// Send String payload to the standard output.
// Message will be followed by the newline.
template.sendBody("direct:in", "Hello Text World");
// Send byte[] payload to the standard output.
// No newline will be added after the message.
template.sendBody("direct:in", "Hello Bytes World".getBytes());
Copy to ClipboardCopied!Toggle word wrapToggle overflow
다음 샘플은 헤더 유형을 사용하여 사용할 스트림을 결정하는 방법을 보여줍니다. 샘플에서는 자체 출력 스트림인 MyOutputStream 을 사용합니다.
다음 샘플에서는 파일 스트림을 지속적으로 읽는 방법을 보여줍니다( UNIX tail 명령과 유사).
Copy to ClipboardCopied!Toggle word wrapToggle overflow
scanStream (pre Camel 2.7) 또는 scanStream + 재시도를 사용하는 하나의 가져 오기는 scanStreamDelay의 각 반복으로 파일을 다시 열고 스캔합니다. NIO2를 사용할 수 있을 때까지 파일이 삭제/생성되는 시기를 안정적으로 감지할 수 없습니다.