camel에선 throttle이라는 옵션을 제공한다.
유량제어를 위해 사용하는 옵션인데, 유량제어가 없다면,
endpoint, 즉 받는 곳에서 처리량 이상으로 입력을 받아 부하가 걸리는 경우가 있다.
endpoint측에서 받을 수 있는 스펙에 한계가 있기 때문에, 보내는 측에서 유량 제어를 걸어
전송되는 속도를 조절하는 것이다.
이를 throttle 이라는 옵션으로 쉽게 제공한다.
1. 10초에 3개 메시지로 전송
from("seda:a")
.throttle(3).timePeriodMillis(10000)
.to("mock:result");
<route>
<from uri="seda:a"/>
<throttle timePeriodMillis="10000">
<constant>3</constant>
</throttle>
<to uri="mock:result"/>
</route>
2. 1초(기본값)에 50개 메시지로 전송
from("seda:a")
.throttle(50)
.to("seda:b");
<route>
<from uri="seda:a"/>
<throttle>
<constant>50</constant>
</throttle>
<to uri="mock:result"/>
</route>
3. 정해진 값 이상 들어오면 에러로 처리하기
정해진 값 이상 들어올 경우 유량제어를 하게 되는데, 굳이 에러로 처리해서 뭔가 결과를 만들고 싶을 경우
사용할 수 있다.
ThrottlerRejectedExecutionException 으로 에러가 남게 된다고 함
from("seda:a")
.throttle(100).rejectExecution(true)
.to("seda:b");
<route>
<from uri="seda:a"/>
<throttle timePeriodMillis="100" rejectExecution="true">
<constant>100</constant>
</throttle>
<to uri="seda:b"/>
</route>
그 외에 throttle 관련 요소는 여기를 참조해서 사용할 수 있다.
https://camel.apache.org/components/2.x/index.html
Home
Supports over 50 Data Formats Camel supports around 50 data formats, allowing to translate messages in multiple formats, and with support from industry standard formats from finance, telco, health-care, and more. See Supported Formats
camel.apache.org
'IT기술 > 개발툴' 카테고리의 다른 글
[IntelliJ] 우클릭 new 에서 java class 사라졌을 때. (0) | 2024.01.06 |
---|---|
Punycode 란 무엇입니까?(퓨니코드) (0) | 2023.07.04 |
[이클립스] lombok 인식 안되는 이유 (2) | 2023.06.13 |
[OpenShift] redhat 에서 밀고있는 솔루션 OpenShift, 통합 관리 프레임워크. (0) | 2023.05.26 |
jattach, java heap dump 뜨기 (0) | 2023.05.26 |