【问题标题】:Unable to access flowVars(MEL) when it routes through until successful message processor in Mule ESB路由时无法访问 flowVars(MEL),直到 Mule ESB 中的消息处理器成功
【发布时间】:2013-10-15 12:04:26
【问题描述】:

您好,我是 mule 新手,第一次开发 mule 项目,请帮助我。在我的主要流程中,我设置了捕获原始有效负载的变量,顺便说一下,如果服务关闭或必须重试 3 次(一直使用到成功),我必须调用一项服务。当它用尽时,它必须通过第二流。无论失败是什么,它都应该只将原始有效负载记录到第二个流中的队列中。所以我试图在 setpayload 处理器中访问 flowVars。但是我遇到了错误,例如- [错误:无法访问:originalPayload;在类:org.mule.el.context.MessagePropertyMapContext] [附近:{... flowVars.originalPayload ....}] 。请找到我的xml配置

 <spring:beans> 
    <spring:bean id="objectStore" class="org.mule.util.store.SimpleMemoryObjectStore"></spring:bean>  
</spring:beans>
<vm:endpoint exchange-pattern="one-way" path="path" name="VM" doc:name="VM"></vm:endpoint>
<flow name="Flow1" doc:name="Flow1">
    <file:inbound-endpoint path="C:\Users\Star Jothi\Desktop\Mule\FilePath1" responseTimeout="10000" doc:name="File"/>

    <byte-array-to-string-transformer doc:name="Byte Array to String"></byte-array-to-string-transformer>
    <set-variable variableName="originalPayload" value="#[payload]" doc:name="Variable"/>
    <set-payload value="#['hi']" doc:name="Set Payload"/>
    <flow-ref name="Flow2" doc:name="Flow Reference"/>

</flow>
<flow name="Flow2" doc:name="Flow2">
    <cxf:proxy-client payload="body" enableMuleSoapHeaders="true" doc:name="SOAP"/>
    <until-successful objectStore-ref="objectStore" maxRetries="2" secondsBetweenRetries="2" deadLetterQueue-ref="VM" doc:name="Until Successful">
        <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="test" method="POST" doc:name="HTTP"/>
    </until-successful>
</flow>
<flow name="Flow3" doc:name="Flow3"> 
   <vm:inbound-endpoint exchange-pattern="one-way" path="path" doc:name="VM"></vm:inbound-endpoint> --> 
    <set-payload value="#[flowVars.originalPayload]" doc:name="Set Payload"></set-payload>  
    <logger message="****#[payload]******" level="INFO" doc:name="Logger"></logger>  
</flow>

请建议我在使用成功之前如何访问 flowVars 并获取原始有效负载。

【问题讨论】:

  • 为什么在until-successful 之后有一个flow-ref:你不希望Flow2 仅在失败的情况下被调用吗?此外,在Flow2 中使用全局声明的 VM 端点而不是重新声明它:`'
  • @DavidDossot - 因为我的流量很大,所以我把它简化了。请立即找到我编辑的流程。我已声明为会话变量,它工作正常。但反过来,如果我在流程 3 中保留 则会出现运行时错误,如您所建议的 - “发现以元素 'vm:endpoint” 开头的无效内容。请提出建议。
  • @Seba - 我正在使用 mule 3.4 版

标签: mule mule-studio mule-el


【解决方案1】:

第一点:

flowVars are accessd in the flow by using #[flowVars['originalPayload']]

第二点:

flowVars are lost from the Mule Message when the message crosses an endpoint.

第三点:

Until Successful is Asynchronous. So irrespective of the success of Until-Successful and HTTP outbound in First flow  the Flow2 is going to get executed.

在您的场景中,您可以在第一个成功的路由器中使用 HTTP 出站和 Flow2 组合。

注意:首次成功不会重试。

希望这会有所帮助。

【讨论】:

  • 是的,它有帮助。谢谢。通过声明为会话变量,它可以正常工作。
猜你喜欢
  • 1970-01-01
  • 2015-01-20
  • 2014-11-07
  • 2012-03-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多