-
CamelBackEnd/Event Streaming 2023. 3. 19. 13:49
Kafka 와 함께 사용하던 Camel 🤔
Camel ?
- System Integrations를 위한 자바 프레임 워크
- Enterprise Intergration patterns 기반 오픈소스 통합 프레임워크
Concepts
- Message : 경로로 전송되는 데이터를 포함 (고유한 식별자가 있으며 본문/ 머리글/ 첨부파일로 구성)
- Exchange : 메세지의 컨테이너
- 메세지가 라우팅 프로세스 중 consumer에 의해 수신될때 만들어짐
- 시스템간 다른 유형의 상호작용 허용
- 단방향 메세지, 요청-응답 메세지 정의
- 대화상태를 포함(홀더객체)
- 속성 및 flag, MEP(Message Exchange Pattern), InOnly/InOut를 포함
- 속성은 String key와 Object 값으로 이루어짐, camel과 Exchange의 처리에 관련된 정보를 저장하는 Component에 의해 사용
- String key와 Object 값의 맵으로 표현되는 Header를 가짐 (부가정보 전달) - Processor : 모든 메시지 처리 단계를 위한 기본 인터페이스
- 사용자 정의 통합 로직을 경로에 추가하는데 사용되는 간단한 Java 인터페이스 - Route: Camel DSL을 사용해 정의한 메시지 처리단계를 연결 (JVM component가 같은 JVM에서 camel contexts 사이를 연결)
- Threading, transaction, error, message duplication
- from consumer endpoint
- 라우트 내의 프로세싱 단계들은 느슨하게 연결되어 있고 서로를 호출하지 않으며, 메시지를 전달하는 대신 Camel Context에 의존 - 경로과 매개변수로서 url이 역할하고 대부분 직접적으로 행해짐 - Context : route에 정의되는 단계를 따라 exchange를 처리하는 엔진
- Component : 전송 또는 공통 camel interface들 뒤에서 전송이나 기술과의 통신을 캡슐화한 라이브러리
- Endpoint : 컴포넌트에 의해 생성되는 주소값
- 컴포넌트가 메시지를 받거나 보내는 디렉토리, 메시지 큐 또는 데이터베이스 테이블 같은 대상자원을 식별
- from() 안에 사용되는 하나의 Endpoint -> consumer endpoint
ex) file://input?noop=true
file - Scheme(식별자)
Builder 형태 표현방식
• .from() : consumer endpoint • .to() : producer endpoint • .marshal() : data/object -> byte 스트림 • .split() : 나눔 • .linger() : 지연 • .parallelProcessing() : 병렬처리 • .constant() : 상수 • .wireTap() : 위치를 나눔 • .batch() : 작업 일괄처리 • .aggregate(constant(true), new GroupedBodtAggregationStrategy()) : 여러 메세지를 하나로 통합 • .eagerCheckCompletion() : 통합된 메세지 확인 • .direct : 메세지 사이를 연결 예시 (Endpoint는 URI로 표현)
- activemq
case1) SEDA component (Link)
from("direct:processOrder")
.to("bean:orderService?method=process")
.to("activemq:queue:order.out");
case2) DSL
<route>
<from uri="activemq:queue:order.in"/>
<to uri="bean:orderService?method=validate"/>
<to uri="direct:processOrder"/>
</route>
'BackEnd > Event Streaming' 카테고리의 다른 글
Kafka (0) 2023.03.19