[CAMEL] File

.·2021년 12월 11일
0

CAMEL

목록 보기
5/5

file 엔드포인트를 이용한 파일 이동

@Component
public class FileRouter extends RouteBuilder{

	@Override
	public void configure() throws Exception {

		// 1) starting end point 정의
		// test-files/input폴더 하위 모든 파일을 가져옴
		// file endpoint로부터 파일을 가져옴
		from("file:test-files/input")
		.log("${body}")
		// 2) ending end point 정의
		// test-files/output 폴더로 내보냄
		// 이때 output폴더는 만들어두지 않아도 자동으로 output폴더를 만든 후, 그 안에 파일들을 넣어줌
		// file endpoint로 파일을 보냄
		.to("file:test-files/output");
	}
}

from endpoint의 파일

파일을 지정된 폴더 위치에 가져다 놓음

to endpoint의 파일

코드 작동 후 파일이 설정한 위치로 이동한 것을 확인

file-test1.json

{
  "id": 1,
  "from": "Seoul",
  "to": "Busan",
  "conversionMultiple": 70
}

로그보기

// 파일의 내용 또한 제대로 읽어옴을 확인
{
  "id": 1,
  "from": "Seoul",
  "to": "Busan",
  "conversionMultiple": 70
}

0개의 댓글

관련 채용 정보