在Mule 3.4中,如何从Java中的“set-variable”标记中获取 Mule 变量集的值?另外,如何获取不同流中 Mule 变量的值,例如flow1中的计数器和flow2中的 prevCounter ?我在Mule的网站上找不到这个。
下面是Mule XML:
<mule xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/2.0/mule-mongo.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd">
<quartz:connector name="Quartz3" validateConnections="true" doc:name="Quartz"/>
<flow name="flow1" doc:name="flow1">
<set-variable variableName="#['counter']" value="#[0]" doc:name="Variable"/>
<flow-ref name="flow2" doc:name="Flow Reference"/>
</flow>
<flow name="flow2" doc:name="flow2">
<logger level="INFO" doc:name="Logger"/>
<set-variable variableName="prevCounter" value="#[flowVars['counter']]" doc:name="Variable"/>
<set-variable variableName="counter" value="#[flowVars['counter']+1]" doc:name="Variable"/>
<choice doc:name="Choice">
<when expression="#[flowVars['counter']==5]">
<logger level="INFO" doc:name="Logger"/>
</when>
<otherwise>
<flow-ref name="flow2" doc:name="Flow Reference"/>
</otherwise>
</choice>
</flow>
</mule>
答案 0 :(得分:2)
您可以使用message.getInvocationProperty('counter')
从Mule消息中获取它们。
流变量仅在消息流中存在,因此您只能在同一个流中访问之前声明的内容(或者像在flow2中那样调用当前流的流)。如果你需要它们在流程之外的某个地方,你必须从流程中将它们发送到那里。
答案 1 :(得分:0)
使用设置变量存储的值可以使用MEL检索flowVars['varName']
。
看看这个:
http://blogs.mulesoft.org/wp-content/uploads/2012/12/refcard-mel.pdf
答案 2 :(得分:0)
请尝试在java中创建会话变量或Flow变量并在java中检索它们不支持你应该使用语法,如 message.getInvocationProperty('name'),如果这些是流量变量