问题是我有两个基于有效载荷类型交替调用的Enrichers。类Foo调用SAP功能模块,Class Bar调用不同的功能模块。 Choice路由器相应地检查有效载荷类型和路由,并且正确。
当子流返回到richher时,richurs工作 - 在这个可重复的场景中除外。
在浏览器中,如果我使用工作类为Foo的URL访问HTTP端点,则它可以正常工作。如果我“停止”mule服务器(localhost),并再次启动它,我可以使用工作类Bar的URL调用HTTP端点。此外,它完美地运作。
但是,我不能做的是让mule app保持运行,并从浏览器中交替调用。当您选择导致不同路由的第二个URL时,会从子流执行错误的richser。
总结:
下面是我们得到的NullPointerException。堆栈跟踪是场景1的一个示例。我已经调用了Foo url一次或多次,然后调用了Bar url。有效负载类型是Bar,但是mule试图调用的Enricher来自Foo richher,它是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>
答案 0 :(得分:0)
在执行选择路由器之前,您是否调试过这个以验证有效负载类?通过Bar URL调用它是否真的是Bar类(重新设置方案1)?如果是,可能is
未按预期工作。您是否尝试使用instanceof
?
答案 1 :(得分:0)
这被证明是一个骡子。他们给我们发了一个补丁。