第一章Camel基本介紹的示例Code
由Camel in Action second edition第一章提供之github連結下載書上範例
並先import至第一章的專案(實際只先用到chapter1-file-copy這個專案)
基本示範純Java Code製做,如上圖
將data資料挾內inbox資料挾裡的message1.xml移至
data下的outbox資料挾內
純Java Code寫法如下:
引用Camel後可將上述Java Code簡化為如下
光是複製檔案用的數行 method,另外為了使用所需的實例程式碼
全都濃縮為一行:
from(“file:data/inbox?noop=true”).to(“file:data/outbox”);
實際執行:
針對專案進行重整Refresh
可以看到outbox出現同樣的檔案
兩支程式可得一樣結果
當然選短的Code寫!
而Camel實作EIPs(Enterprise integration patterns)邏輯
書本開頭即強調要完整應用Camel者需瞭解EIPs!