我在骡子是一个小问题处理数据.. 我选择使用SQL查询类似如下: -如何获得使用MEL如果选择SQL返回Null
<jdbc-ee:query key="RetriveQuery" value="Select NAME,ID from getData where ID=111 "/>
现在,从这里我会得到使用MEL像#[message.payload[0].NAME]
和
#[message.payload[0].ID]
现在它可能是ID=111
不存在的情况下的值.. 所以,在这种情况下,我怎么能检查查询是否返回一个空负载或不使用MEL? ?..
到目前为止,我试图与选择路由器类似如下: - :
-<choice doc:name="Choice">
<when expression="#[message.payload[0].ID == null]">
//Then print in logger like Sorry!! Data not available
否则每当我使用这个我得到以下异常使用MEL
打印在记录仪中的数据
Exception stack is:
1. Index: 0, Size: 0 (java.lang.IndexOutOfBoundsException)
java.util.ArrayList:604 (null)
2. [Error: message.payload[0].ID: array index out of bounds.]
[Near : {... message.payload[0].ID == null ....}]
^
[Line: 1, Column: 1] (org.mule.mvel2.PropertyAccessException)
org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer:426 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/mvel2/PropertyAccessException.html)
3. Execution of the expression "message.payload[0].ID == null" failed. (org.mule.api.expression.ExpressionRuntimeException)
org.mule.el.mvel.MVELExpressionLanguage:202 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
4. Execution of the expression "message.payload[0].ID == null" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: ArrayList (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getCollectionProperty(ReflectiveAccessorOptimizer.java:776)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
请帮助..我如何得到ID是否存在或不使用MEL?