我是Mule的新手,当我正在运行我的Mule应用程序时,我正在设置一个值为' op'来自查询参数。后来我使用相同的方法来确定选择中的哪个选项'被执行。不知何故,我看到每次将值设置为' div'在日志中我发现它是由于调用范围属性(我猜)。
有人可以帮助我吗,下面是日志,下面是xml。
INVOCATION scoped properties:
**op**=div
var1=12
var2=3
INBOUND scoped properties:
accept=*/*
accept-encoding=gzip, deflate, sdch
accept-language=en-US,en;q=0.8
cache-control=no-cache
connection=keep-alive
host=localhost:8081
http.listener.path=/samples
http.method=GET
http.query.params=ParameterMap{[**op**=[sub], a=[12], b=[3]]}
http.query.string=**op**=sub&a=12&b=3
http.relative.path=/samples
http.remote.address=/127.0.0.1:8503
http.request.path=/samples
http.request.uri=/samples?op=sub&a=12&b=3
http.scheme=http
http.uri.params=ParameterMap{[]}
http.version=HTTP/1.1
postman-token=8cfdd0be-5204-1d8a-9b0e-c829c7ddeb9e
user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
OUTBOUND scoped properties:
SESSION scoped properties:
XML
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:validation="http://www.mulesoft.org/schema/mule/validation" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/validation http://www.mulesoft.org/schema/mule/validation/current/mule-validation.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<db:mysql-config name="MySQL_Configuration" host="mudb.mulesoft-training.com" port="3306" user="mule" password="mule" database="training" doc:name="MySQL Configuration"/>
<sub-flow name="sub_expression">
<expression-component doc:name="sub exp"><![CDATA[import java.lang.Double;
double firstValue = flowVars.var1;
double secondValue = flowVars.var2;
double result = (firstValue) - (secondValue);
payload = result]]></expression-component>
<set-payload value="Result is: #[payload]" doc:name="Set Payload"/>
</sub-flow>
<sub-flow name="Multiplication_expression">
<expression-component doc:name="mul Exp"><![CDATA[import java.lang.Double;
double firstValue = flowVars.var1;
double secondValue = flowVars.var2;
double result = (firstValue) * (secondValue);
payload = result]]></expression-component>
<set-payload value="Result is: #[payload]" doc:name="Set Payload"/>
</sub-flow>
<sub-flow name="Div_expression">
<expression-component doc:name="Div Exp"><![CDATA[import java.lang.Double;
double firstValue = flowVars.var1;
double secondValue = flowVars.var2;
double result = (firstValue) / (secondValue);
payload = result]]></expression-component>
<set-payload value="Result is: #[payload]" doc:name="Set Payload"/>
</sub-flow>
<sub-flow name="Set_Flow_Variables">
<set-variable variableName="var1" value="#[message.inboundProperties.get('http.query.params').get('a')]" metadata:id="8354c885-e13c-4ed8-be46-38e65107898f" doc:name="Variable1"/>
<set-variable variableName="var2" value="#[message.inboundProperties.get('http.query.params').get('b')]" metadata:id="d18ef85a-f8d6-4a0b-9076-159ff9b51bca" doc:name="Variable2"/>
<set-variable variableName="op" value="#[message.inboundProperties.get('http.query.params').get('op')] " metadata:id="22fd48bf-7d8c-4b09-a0a3-60f4a7ccbd89" doc:name="Variable"/>
</sub-flow>
<sub-flow name="Choice">
<choice tracking:enable-default-events="true" doc:name="Choice">
<when expression="#[flowVars.op = 'div']">
<flow-ref name="Div_expression" doc:name="Div_expression"/>
</when>
<when expression="#[flowVars.op = 'mul']">
<flow-ref name="Multiplication_expression" doc:name="Multiplication_expression"/>
</when>
<when expression="#[flowVars.op = 'sub']">
<flow-ref name="sub_expression" doc:name="sub_expression"/>
</when>
<otherwise>
<set-payload value="invalid operator" doc:name="Set Payload"/>
</otherwise>
</choice>
</sub-flow>
<flow name="sampleprojectFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/samples" allowedMethods="GET,POST" doc:name="HTTP"/>
<flow-ref name="Set_Flow_Variables" doc:name="Set_Flow_Variables"/>
<flow-ref name="Choice" doc:name="Choice"/>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
&#13;
答案 0 :(得分:0)
问题是相等运算符。不正确的是,您改为使用作业。
#[flowVars.op = 'div']
#[flowVars.op == 'div']