【问题标题】:Mule JSON Payload null check in Choice Filter选择过滤器中的 Mule JSON Payload null 检查
【发布时间】:2018-06-27 03:52:54
【问题描述】:

我在这里做错了吗?即使 json 有效载荷是 [],它也会使用默认值而不是错误日志。

<choice doc:name="If Payload is Null">
    <when expression="#[payload == empty]">
        <mule-logger-module:logger-exception message="Null Payload" doc:name="Log Error"/>
    </when>
    <otherwise>
        <mule-logger-module:log-default message="Payload Received" type="EXIT" doc:name="Log End"/>
    </otherwise>
</choice>

【问题讨论】:

  • 在这之前是一个 json 字符串吗?还是一个数组?

标签: json mule mule-esb


【解决方案1】:

先转换为 Maps 数组,然后使用 MEL 表达式测试空:

<json:json-to-object-transformer
            returnClass="java.util.HashMap[]" doc:name="JSON to Object" />
<choice doc:name="If Payload is Null">
<when expression="#[payload == empty]">
    <mule-logger-module:logger-exception message="Null Payload" doc:name="Log Error"/>
</when>
<otherwise>
    <mule-logger-module:log-default message="Payload Received" type="EXIT" doc:name="Log End"/>
</otherwise>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-19
    • 1970-01-01
    • 2015-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    相关资源
    最近更新 更多