0
votes

I'm trying to create a choice router in my Mule application that will do something based on the response code received from an HTTP Outbound Endpoint. My config is as below - I followed the answers provided in 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>

Yet, I get the following error:

********************************************************************************
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)
********************************************************************************

The http.status inbound property is clearly in the scope as the output from my logger immediately before the choice router is as below:

{
  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:
}

Can anyone identify why I'm having this issue? Thanks in advance.

1

1 Answers

3
votes

You need to place your operator inside the mule expression brackets like so:

<when expression="#[message.inboundProperties['http.status'] == '200']">