mule - 如何在 Mule 3 中返回 null 而不是异常消息
问题描述
有人可以帮助如何返回null而不是返回异常作为输出json。
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:validation="http://www.mulesoft.org/schema/mule/validation" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:db="http://www.mulesoft.org/schema/mule/db" 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/db http://www.mulesoft.org/schema/mule/db/current/mule-db.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/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/validation http://www.mulesoft.org/schema/mule/validation/current/mule-validation.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="9097" doc:name="HTTP Listener Configuration"/>
<validation:config name="Validation_Configuration" doc:name="Validation Configuration"/>
<flow name="testFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" allowedMethods="GET" doc:name="HTTP"/>
<db:select config-ref="Generic_Database_Configuration" doc:name="Database">
<db:dynamic-query><![CDATA[SELECT * FROM SALESIT_DB.SALESIT_SC3VIS_BR.abcd trx where trx.employee_id= '1232' and trx.so_number='abc']]></db:dynamic-query>
</db:select>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<dw:transform-message doc:name="Transform Message" metadata:id="3581fe3a-a6f9-4071-b861-fcf16396358a">
<dw:input-payload mimeType="application/java"/>
<dw:set-payload><![CDATA[
%dw 1.0
%output application/json
---
payload filter (($.payload != 0))
]]></dw:set-payload>
</dw:transform-message>
</flow>
</mule>
异常是无法识别数值“abc”(net.snowflake.client.jdbc.SnowflakeSQLException)。
有没有办法我们可以打印 null 作为输出有效负载而不是打印异常。
有人可以帮忙。
谢谢,尼基尔
解决方案
将 db:select 提取到单独的流中,然后使用流引用调用它。
在提取的流中定义 a
catch-exception-strategy
并在其中将 setPayload 设置为 null。
推荐阅读
- apache-camel - 如何在 Apache Camel 中创建 ConsumerTemplate
- javascript - React + Redux:等待异步操作解决
- python - 根据另一列中的条件查找列中唯一值的总数
- typescript - 打字稿:将数组映射到顺序函数输入/输出
- python - 正在分析的 pyspark udf 打印行
- java - 如何使用 Java Apache POI 从 excel 中删除整行?
- excel - 如何修改excel文档,另存为pdf并用Python打印
- c# - 具有缓存结果的属性或 get 方法
- angular - 如何在 Angular 4 中删除正文标签边距?
- javascript - MongoDB - 如何检索多个数据并表示为值数组?