我正在尝试在我的Mule应用程序中创建一个选择路由器,该路由器将根据从HTTP出站端点接收的响应代码执行某些操作。我的配置如下 - 我按照this previous question中提供的答案:
<set-variable variableName="http.disable.status.code.exception.check" value="true" doc:name="Variable"/>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="hello" contentType="text/xml" method="POST" doc:name="HTTP"/>
<logger level="INFO" doc:name="Logger"/>
<choice doc:name="Choice">
<when expression="#[message.inboundProperties['http.status']] == 200">
<logger level="DEBUG" message="HTTP SUCCESS" doc:name="Debug"/>
</when>
<otherwise>
<logger level="DEBUG" message="HTTP FAILURE" doc:name="Debug"/>
</otherwise>
</choice>
然而,我收到以下错误:
********************************************************************************
Message : Execution of the expression "message.inboundProperties['http.status']] == 20" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: ReleasingInputStream
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. [Error: could not access: ]; in class: java.lang.String]
[Near : {... message.inboundProperties['htt ....}]
^
[Line: 1, Column: 1] (org.mvel2.PropertyAccessException)
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer:690 (null)
2. Execution of the expression "message.inboundProperties['http.status']] == 20" failed. (org.mule.api.expression.ExpressionRuntimeException)
org.mule.el.mvel.MVELExpressionLanguage:218 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
3. Execution of the expression "message.inboundProperties['http.status']] == 20" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: ReleasingInputStream (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:35 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
[Error: could not access: ]; in class: java.lang.String]
[Near : {... message.inboundProperties['htt ....}]
^
[Line: 1, Column: 1]
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:690)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanPropertyAO(ReflectiveAccessorOptimizer.java:472)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:374)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
http.status入站属性显然在范围内,作为我的记录器在选择路由器之前的输出如下:
{
id=dece5e82-db50-11e3-94e6-9552f33cb636
payload=org.mule.transport.http.ReleasingInputStream
correlationId=<not set>
correlationGroup=-1
correlationSeq=-1
encoding=UTF-8
exceptionPayload=<not set>
Message properties:
INVOCATION scoped properties:
http.disable.status.code.exception.check=true
http.method=POST
INBOUND scoped properties:
Connection=true
Content-Length=0
Content-Type=text/plain
Date=Wed, 14 May 2014 11:16:53 +0100
Keep-Alive=true
Server=Mule Core/3.4.0
http.headers={Date=Wed, 14 May 2014 11:16:53 +0100, Content-Length=0, Keep-Alive=true, Connection=true, Content-Type=text/plain, Server=Mule Core/3.4.0}
http.method=POST
http.query.params={}
http.query.string=
http.request=http://localhost:8081/hello
http.status=200
http.version=HTTP/1.1
OUTBOUND scoped properties:
MULE_ENCODING=UTF-8
MULE_SESSION=rO0ABXNyACNvcmcubXVsZS5zZXNzaW9uLkRlZmF1bHRNdWxlU2Vzc2lvbi7rdtEW7GGKAwAEWgAFdmFsaWRMAA1mbG93Q29uc3RydWN0dAAmTG9yZy9tdWxlL2FwaS9jb25zdHJ1Y3QvRmxvd0NvbnN0cnVjdDtMAAJpZHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wAD3NlY3VyaXR5Q29udGV4dHQAJ0xvcmcvbXVsZS9hcGkvc2VjdXJpdHkvU2VjdXJpdHlDb250ZXh0O3hwAXB0ACRkZWJiYzBjYi1kYjUwLTExZTMtOTRlNi05NTUyZjMzY2I2MzZwc3IAJWphdmEudXRpbC5Db2xsZWN0aW9ucyRTeW5jaHJvbml6ZWRNYXAbc/kJS0s5ewMAAkwAAW10AA9MamF2YS91dGlsL01hcDtMAAVtdXRleHQAEkxqYXZhL2xhbmcvT2JqZWN0O3hwc3IAJG9yZy5tdWxlLnV0aWwuQ2FzZUluc2Vuc2l0aXZlSGFzaE1hcJ3R2e9nRc4AAwAAeHB3DD9AAAAAAAAQAAAAAHhxAH4ACXh4
SESSION scoped properties:
}
任何人都可以确定我遇到此问题的原因吗?提前谢谢。