gpt4 book ai didi

mule - 将 Mule 1.3 "model"元素转换为 Mule 3 等效项

转载 作者:行者123 更新时间:2023-12-04 18:21:13 28 4
gpt4 key购买 nike

我正在将 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-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 描述符使用 BridgeComponent来自 Mule 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) 另一个 mule 描述符在其 <outbound-router> 中有一个“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信息。但是,“urlFromMessage”属性在 Mule 3 的 RestServiceWrapper 版本中不存在。类(class)。我应该在 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>

最佳答案

  • 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) 使用 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) 大多数 Mule 默认组件现在都可以作为 XML 元素使用,因此您确实需要使用:
    <http:rest-service-component serviceUrl="..." />
    urlFromMessage不见了:相反,您可以使用 Mule expression以动态方式从飞行消息中提取 URL。例如,如果 URL 在名为 svcURL 的入站属性中提供。利用:
    <http:rest-service-component serviceUrl="#[header:INBOUND:svcURL]" />

    关于mule - 将 Mule 1.3 "model"元素转换为 Mule 3 等效项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10638206/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com