Mule ESB中entry-point-resolver的使用(1) 總論

前面介紹Mule ESB使用的系列文章中咱們使用了自定義的Java Transformer和Java Component,用於接收和處理Mule Message。然而咱們使用的Transformer和Component都必須實現AbstractTransformer接口或者org.mule.api.lifecycle.Callable接口,這使得普通的POJO對象沒法直接被Mule ESB流程引用,必須填寫實現接口的代碼。這樣不只增長了代碼開發的工做量,並且進行單元測試時沒法脫離Mule ESB Container進行,具備很大的侷限性。api

   從Mule ESB 3開始,引入了entry point resolver機制,Mule Flow在引用自定義Component時,同時定義對應的entry point resolver, 使得在Component沒有實現接口的前提下,Mule ESB能夠準確匹配到Component對應方法,將Mule Message傳送給這些方法處理。Mule ESB將這一策略稱爲entry-point resolution strategy(EPRS),下圖顯示了Mule ESB如何使用EPRS進行Mule Message傳遞(Mule in Action 第二版的6.1中原來有配圖,不過它基於Mule ESB 3.3版本,已經不適用於當前Mule ESB 3.8版本,所以我從新繪製了流程圖)單元測試

1)當消息到達Flow中定義的Component時,Mule會檢查是否認義了EPRS(能夠定義在Flow級別,Component級別,後者定義的entry-point resolver能夠覆蓋前者定義的entry-point resolver),若是沒有定義,Mule會使用默認的entry-point resolver。測試

  2)Mule根據entry-point resolver尋找匹配的entry point,若是沒有找到,會拋出Failed find entry point for component的異常消息。若是找到匹配的entry point,不論有多少個,會執行第一個匹配的entry point。component

Mule ESB中定義的entry point resolver有如下幾種:orm

  • Callable Entry Point Resolver
  • Property Entry Point Resolver
  • Method Entry Point Resolver
  • Reflection Entry Point Resolver
  • Array Entry Point Resolver
  • No Arguments Entry Point Resolver
  • Custom Entry Point Resolver

 下面將對這些Entry Point Resolver進行逐一介紹對象

相關文章
相關標籤/搜索