2012-05-17 28 views
2

我將Mule 1.3應用程序升級到Mule 3.2.1(最新版本)。 Mule 1.3配置文件有一個「模型」元素和許多「mule-descriptor」子元素。將Mule 1.3「model」元素轉換爲Mule 3等效物

<model name="theModel"> 
    <mule-descriptor name="theName" implementation="com.company.SomeClass"> 
    <inbound-router> 
     <endpoint address="servlet://service/foo" transformers="ACustomTransformer" responseTransformers="AnotherCustomTransformer" /> 
     <endpoint address="vm://anEndpoint"/> 
    </inbound-router> 
    <outbound-router> 
     <router className="org.mule.routing.outbound.FilteringOutboundRouter"> 
     <endpoint address="Authenticator"> 
      <properties> 
      <property name="propName" value="propValue" /> 
      </properties> 
     </endpoint> 
     <filter expression="/data = null" className="org.mule.routing.filters.xml.JXPathFilter" /> 
     </router> 
     <router className="org.mule.routing.outbound.OutboundPassThroughRouter"> 
     <endpoint address="RequestValidator" /> 
     </router> 
    </outbound-router> 
    <properties> 
     <property name="someProp" value="someValue" /> 
    </properties> 
    </mule-descriptor> 
    <!-- more <mule-descriptor> elements --> 
</model> 

我該如何將它轉換爲它的騾子3等值?謝謝。


編輯 - 2012/5/29

1)一些騾子描述符中有入站路由器指向自己。

<mule-descriptor name="theName" implementation="com.company.SomeClass"> 
    <inbound-router> 
    <endpoint address="theName" /> 
    </inbound-router> 
</mule-descriptor> 

這些應該如何轉換爲Mule 3流?當我使用你的答案中的信息將它們轉換爲流程時,我在啓動時收到一條錯誤消息,這似乎表示它無法引用該流程,因爲它仍在創建(如循環依賴項):

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ref:RequestValidator.20': Cannot resolve reference to bean 'RequestValidator' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'RequestValidator': Cannot create inner bean '(inner bean)' of type [org.mule.config.spring.factories.InboundEndpointFactoryBean] while setting bean property 'messageSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': 1 constructor arguments specified but no matching constructor found in bean '(inner bean)' (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)

2)一個mule描述符使用Mule API中的BridgeComponent類作爲其實現。這些應該如何處理?這個類並不在騾3.存在

<mule-descriptor name="theName" implementation="org.mule.components.simple.BridgeComponent"> 
    <inbound-router> 
    <endpoint address="vm://theInboundAddress" /> 
    </inbound-router> 
    <outbound-router> 
    <router className="org.mule.routing.outbound.FilteringOutboundRouter"> 
     <endpoint address="vm://theOutboundAddress" /> 
    </router> 
    </outbound-router> 
</mule-descriptor> 

3)另一個騾描述符在其<outbound-router>元a「matchAll」屬性。這應該如何轉換爲Mule 3流?

<mule-descriptor name="theName" implementation="com.company.SomeClass"> 
    <inbound-router> 
    <endpoint address="servlet://theInboundEndpoint" /> 
    </inbound-router> 
    <outbound-router matchAll="true"> 
    <router className="org.mule.routing.outbound.OutboundPassThroughRouter"> 
     <endpoint address="firstOutboundEndpoint" /> 
    </router> 
    <router className="org.mule.routing.outbound.FilteringOutboundRouter" transformer="MyTransformer"> 
     <endpoint address="vm://secondOutboundEndpoint" /> 
     <filter pattern="Error*" className="org.mule.routing.filters.WildcardFilter" /> 
    </router> 
    </outbound-router> 
</mule-descriptor> 

4)的騾1.x的配置具有<endpoint-identifier>元件用相同的那些的一些<mule-descriptor>元素的名稱的名稱屈指可數。這些名稱也被用作<mule-descriptor>中的端點地址。例如:

<endpoint-identifiers> 
    <endpoint-identifier name="TheEndpointName" value="vm://theEndpointAddress" /> 
</endpoint-identifiers> 

... 

<model name="..."> 
    <mule-descriptor name="TheEndpointName" implementation="..."> 
    <inbound-router> 
     <endpoint address="TheEndpointName" /> 
    </inbound-router> 
    ... 
    </mule-descriptor> 
    ... 
</model> 

我的猜測是,騾3等效應該看起來像下面的代碼。它是否正確?

<flow name="TheEndpointName"> 
    <!-- 
    My first guess was: 
    <inbound-endpoint ref="TheEndpointName" /> 
    --> 
    <vm:inbound-endpoint path="theEndpointAddress" /> 
    ... 
</flow> 

再次感謝您。

EDIT 2012年5月30日

5)一些騾描述符使用RestServiceWrapper類從騾API。當我將它轉換爲一個騾子3 <flow>,我得到這個錯誤:

The required object/property 'serviceUrl' is null

我注意到,騾子描述在騾1.x的配置設置一個名爲「urlFromMessage」屬性,這似乎是說即,而不是XML配置文件中提供的URL,它將作爲屬性提供給Mule消息。但是,在「Mule 3」版本的RestServiceWrapper類中,「urlFromMessage」屬性不存在。我應該在Mule 3中使用不同的組件類嗎?由於這個類是Mule API的一部分,是否存在我應該使用的標準XML標記?謝謝。

<mule-descriptor name="theName" implementation="org.mule.components.rest.RestServiceWrapper"> 
    <inbound-router> 
    ... 
    </inbound-router> 
    <properties> 
    <property name="urlFromMessage" value="true" /> 
    </properties> 
</mule-descriptor> 

回答

4
  • model已被棄用。
  • flow已經取代mule-descriptor

更多的人,看你的配置轉換爲騾子3:

<flow name="theName"> 
    <composite-source> 
     <vm:inbound-endpoint path="anEndpoint"> 
      <transformer ref="ACustomTransformer" /> 
      <response> 
       <transformer ref="AnotherCustomTransformer" /> 
      </response> 
     </vm:inbound-endpoint> 
     <servlet:inbound-endpoint path="/service/foo" /> 
    </composite-source> 
    <component> 
     <singleton-object class="com.company.SomeClass"> 
      <property key="someProp" value="someValue" /> 
     </singleton-object> 
    </component> 
    <outbound-endpoint ref="Authenticator"> 
     <expression-filter expression="/data = null" 
      evaluator="jxpath" /> 
     <property key="propName" value="propValue" /> 
    </outbound-endpoint> 
    <outbound-endpoint ref="RequestValidator" /> 
</flow> 

注意:這個配置是有效的騾子3.2.1,但我不能保證它完全符合你的要求,你必須測試和調整它!

更多的答案:

1)使用流和端點不同的名稱,他們現在註冊爲幕後個別豆,因此不能共享相同的名稱。這給了:

<flow name="theFlowName"> 
    <inbound-endpoint ref="theInboundName" /> 
    <component> 
     <singleton-object class="com.company.SomeClass" /> 
    </component> 
</flow> 

2)使用Bridge pattern

<pattern:bridge name="theName" 
       inboundAddress="vm://theInboundAddress" 
       outboundAddress="vm://theOutboundAddress" /> 

3)使用all routing message processor和使用processor-chain將幾個消息處理器爲一個:

<flow name="theName"> 
    <servlet:inbound-endpoint path="/theInboundEndpoint" /> 
    <component> 
     <singleton-object class="com.company.SomeClass" /> 
    </component> 
    <all> 
     <outbound-endpoint ref="firstOutboundEndpoint" /> 
     <processor-chain> 
      <transformer ref="MyTransformer" /> 
      <wildcard-filter pattern="Error*" /> 
      <vm:outbound-endpoint path="secondOutboundEndpoint" /> 
     </processor-chain> 
    </all> 
</flow> 

4)你可以在流程中聲明全局端點,並且您需要爲端點和流程使用不同的名稱,所以實際的Mule 3配置相當於:

<vm:endpoint name="TheEndpointName" path="theEndpointAddress" /> 

<flow name="TheFlowName"> 
    <inbound-endpoint ref="TheEndpointName" /> 
    <component> 
     <singleton-object class="..." /> 
    </component> 
</flow> 

5)多數騾子默認組件現在作爲XML元素,讓你確實需要使用:

<http:rest-service-component serviceUrl="..." /> 

urlFromMessage消失;相反,你可以使用一個Mule expression從在提取網址動態消息。例如,如果URL是在名爲svcURL的入站屬性中提供的,請使用:

<http:rest-service-component serviceUrl="#[header:INBOUND:svcURL]" /> 
+0

嗨大衛,我很感謝您的幫助。我仍在研究騾描述符,很快就會有更多問題... – Michael

+0

您是否接受這個問題並在您的轉換過程中提出新問題? btw祝你好運! –

+0

David我不想接受它,但我還沒有嘗試過運行我的Mule應用程序。 – Michael

相關問題