【发布时间】:2016-02-25 01:23:01
【问题描述】:
问题是我有两个根据负载类型交替调用的 Enricher。 Foo 类调用一个 SAP 函数模块,而 Bar 类调用一个不同的函数模块。 Choice 路由器会检查有效负载类型并相应地正确地进行路由。
当子流返回到浓缩器时,浓缩器开始工作——在这种可重复的场景中除外。
从浏览器中,如果我使用 Foo 类的 URL 访问 HTTP 端点,它可以完美运行。如果我“停止”mule 服务器(localhost),然后重新启动它,我可以使用适用于类 Bar 的 URL 调用 HTTP 端点。而且,它工作得很好。
但是,我不能做的是让骡子应用程序运行,并交替来自浏览器的调用。当您选择导致不同路由的第二个 url 时,会从子流中执行错误的扩充器。
总结一下:
- 一遍又一遍地调用Foo url就好了,然后调用Bar url--it 失败。
- 停止/重启服务器
- 一遍遍调用Bar url就好了,然后调用Foo url--it 失败。
下面是我们得到的 NullPointerException。 stacktrace 是场景 1 的一个示例。我已经调用了 Foo url 一次或多次,然后调用了 Bar url。有效负载类型是 Bar,但 mule 试图调用的 Enricher 来自 Foo 丰富器,它为 null。
ERROR 2015-07-18 07:33:35,296 [[vistaar].connector.http.mule.default.receiver.02] org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
Message : Execution of the expression "payload.bapiFunction=__object_for_enrichment" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: Bar
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.mvel2.DataConversion:129 (null)
2. error calling method: com.company.foo.**Foo.**setBapiFunction (java.lang.RuntimeException)
org.mule.mvel2.optimizers.impl.refl.nodes.SetterAccessor:46 (null)
3. Execution of the expression "payload.bapiFunction=__object_for_enrichment" failed. (org.mule.api.expression.ExpressionRuntimeException)
org.mule.el.mvel.MVELExpressionLanguage:202 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
4. Execution of the expression "payload.bapiFunction=__object_for_enrichment" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: **Bar** (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.mvel2.DataConversion.convert(DataConversion.java:129)
at org.mule.mvel2.optimizers.impl.refl.nodes.SetterAccessor.setValue(SetterAccessor.java:25)
at org.mule.mvel2.optimizers.impl.refl.nodes.SetterAccessor.setValue(SetterAccessor.java:41)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
这是我的流程...
<foreach doc:name="For Each" collection="payload.getObjectList()" counterVariableName="count">
<expression-component doc:name="Build Bapi Pojo"><![CDATA[payload.buildBapiFunction();]]></expression-component>
<choice doc:name="Choice">
<when expression="payload is com.mycompany.project.Foo">
<enricher source="#[payload]" target="#[payload.bapiFunction]" doc:name="Enrich w/Sales Deal RFC results">
<flow-ref name="sales-deal-rfc-flow" doc:name="RFC" />
</enricher>
</when>
<when expression="payload is com.mycompany.project.Bar">
<enricher source="#[payload]" target="#[payload.bapiFunction]" doc:name="Enrich w/Price Struct RFC results">
<flow-ref name="price-struct-rfc-flow" doc:name="RFC" />
</enricher>
</when>
<otherwise>
<logger message="#['Should never be here.']" level="INFO" doc:name="Impossible" />
</otherwise>
</choice>
</foreach>
<sub-flow name="sales-deal-rfc-flow" doc:name="sales-deal-rfc-flow">
<data-mapper:transform config-ref="Pojo_To_Xml" doc:name="Pojo To Xml" />
<sap:outbound-endpoint exchange-pattern="request-response" connector-ref="SAP" type="function" functionName="ZFM_OPROI1110_SDCR"
xmlVersion="2" outputXml="true" evaluateFunctionResponse="true" responseTimeout="10000" doc:name="SAP" />
<data-mapper:transform config-ref="Xml_To_Pojo" doc:name="Xml To Pojo" />
</sub-flow>
<sub-flow name="price-struct-rfc-flow" doc:name="price-struct-rfc-flow">
<data-mapper:transform config-ref="Pojo_To_Xml_1" doc:name="Pojo To Xml" />
<sap:outbound-endpoint connector-ref="SAP" type="function" functionName="ZFM_OPROI1105_PS" xmlVersion="2" outputXml="true"
evaluateFunctionResponse="true" responseTimeout="10000" doc:name="SAP" exchange-pattern="request-response" />
<data-mapper:transform config-ref="Xml_To_Pojo_1" doc:name="Xml To Pojo" />
</sub-flow>
【问题讨论】:
标签: mule mule-studio