2

我正在将 Mule 1.3 应用程序升级到 Mule 3.2.1(最新版本)。Mule 1.3 配置文件有一个“model”元素和许多“mule-descriptor”子元素。

<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>

我如何将其转换为等效的 Mule 3?谢谢。


编辑 - 2012 年 5 月 29 日

1)一些 mule 描述符有指向自己的入站路由器。

<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-descriptor 使用BridgeComponentMule API 中的类作为其实现。这些应该如何处理?这个类在 Mule 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>另一个 mule 描述符在其元素中具有“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) Mule 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>

我的猜测是 Mule 3 等效项应该类似于下面的代码。这个对吗?

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

再次感谢你。

编辑 2012 年 5 月 30 日

5)一些 mule 描述符使用RestServiceWrapper来自 Mule API 的类。当我将其转换为 Mule 3<flow>时,出现此错误:

The required object/property 'serviceUrl' is null

我注意到 Mule 1.x 配置中的 mule-descriptor 设置了一个名为“urlFromMessage”的属性,这似乎是说,而不是在 XML 配置文件中提供 URL,它将作为属性提供给 Mule信息。RestServiceWrapper但是,“urlFromMessage”属性在 Mule 3 版本的类中不存在。我应该在 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

1 回答 1

4
  • model已被弃用。
  • flow已更换mule-descriptor

还有更多,请查看为 Mule 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>

注意:此配置对 Mule 3.2.1 有效,但我不能保证它完全符合您的要求,您必须对其进行测试和调整!

更多答案:

1) 为流和端点使用不同的名称,它们现在在后台注册为单独的 bean,因此不能共享相同的名称。这给出了:

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

2)使用桥接模式

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

3)使用all路由消息处理器,并使用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) 大多数 Mule 默认组件现在都可以作为 XML 元素使用,因此您确实需要使用:

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

urlFromMessage不见了:相反,您可以使用Mule 表达式以动态方式从飞行消息中提取 URL。例如,如果 URL 在名为svcURLuse 的入站属性中提供:

<http:rest-service-component serviceUrl="#[header:INBOUND:svcURL]" />
于 2012-05-17T15:29:21.067 回答