差異處
這裏顯示兩個版本的差異處。
Both sides previous revision 前次修改 下次修改 | 前次修改 | ||
java:apache_camel:aggregator:helloworld [2019/03/17 22:04] tony |
java:apache_camel:aggregator:helloworld [2023/06/25 09:48] (目前版本) |
||
---|---|---|---|
行 2: | 行 2: | ||
====== Camel - Aggregator Hello World ====== | ====== Camel - Aggregator Hello World ====== | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Camel Aggregator提供開發人員能夠將大量訊息合成一個的功能。假設你的系統會接受外來通知,並將內容寫進資料庫中;一次連線寫一筆資料會比較快,還是透過一次連線寫入五筆資料快呢? 正常來說,一次連線寫入五筆同屬性資料會是比較快的。它與[[java:apache_camel:throttler:helloworld|Throttler]]的最大區別在於,Throttler限制了client的請求,而Aggreator則是收集起來一次"後送"。因此,如果使用Aggreator,你的程式必須要有對應的處理方式。\\ | + | Camel Aggregator提供開發人員能夠將大量訊息合成一個的功能。假設你的系統會接受外來通知,並將內容寫進資料庫中;一次連線寫一筆資料會比較快,還是透過一次連線寫入五筆資料快呢? 正常來說,一次連線寫入五筆同屬性資料會是比較快的。它與[[java:apache_camel:throttler:helloworld|Throttler]]的最大區別在於,Throttler限制了client的請求,而Aggreator則是收集起來一次"後送"。因此,如果使用Aggreator,你的程式必需要有對應的處理方式。\\ |
\\ | \\ | ||
我將透過HTTP GET請求/events/{id}做為範例,說明如何使用Aggregator去將單位時間內的請求,以{id}去分組並Aggredate成各別分組訊息。本篇文章中使用到兩個RouteBuilder,分別為RestRouteBuilder與AggregatorGroupRouteBuilder。RestRouteBuilder負責REST核心相關設定,可參考[[java:apache_camel:throttler:helloworld|先前文章]]。接下來直接說明AggregatorGroupRouteBuilder。 | 我將透過HTTP GET請求/events/{id}做為範例,說明如何使用Aggregator去將單位時間內的請求,以{id}去分組並Aggredate成各別分組訊息。本篇文章中使用到兩個RouteBuilder,分別為RestRouteBuilder與AggregatorGroupRouteBuilder。RestRouteBuilder負責REST核心相關設定,可參考[[java:apache_camel:throttler:helloworld|先前文章]]。接下來直接說明AggregatorGroupRouteBuilder。 | ||
+ | \\ | ||
+ | \\ | ||
+ | (程式碼可參考[[https://github.com/frank007love/CamelPractice|link]]) | ||
===== AggregatorGroupRouteBuilder ===== | ===== AggregatorGroupRouteBuilder ===== | ||
<code java> | <code java> |