如何对 JSON 消息的多个参数使用过滤器
How to use filter for more than one parameter of a JSON message
我使用的是 ESB-4.9.0 版本。
必须基于两个过滤逻辑继续 ESB 中介流。 JSON 消息在中介流中转换。目前,我正在使用两个过滤器调解器来实现这一点。 是否有可能使用单个过滤器中介来实现相同的场景?
输入JSON消息
{
"filterId": "CorrectId",
"approvalStatus": "approved",
"lifeCycleStatus": "BRANCH_READY",
"channelData": [
{
"status": "pending",
"indexId": "correctIndexId",
"description": "Test Description"
}
]
}
使用的ESB Synapse部分
<filter description="" regex="CorrectId" source="json-eval($.filterId)">
<then>
<filter description="" regex="correctIndexId" source="json-eval($.indexId)">
<then>
<!-- continue the mediation flow-1-->
</then>
<else>
<!-- continue the mediation flow-2-->
</else>
</filter>
</then>
<else>
<drop/>
</else>
</filter>
是的,这可以通过过滤器调解器和 xpath concat
函数实现:
<resource methods="POST" uri-template="/onefilter">
<inSequence>
<property name="filterId" expression="json-eval($.filterId)"/>
<property name="correctIndexId" expression="json-eval($.channelData[0].indexId)"/>
<property name="combinedID" expression="fn:concat($ctx:filterId, $ctx:correctIndexId)"/>
<filter source="$ctx:combinedID" regex="CorrectIdcorrectIndexId">
<then>
<log level="custom">
<property name="message" value="continue 1"/>
</log>
<drop/>
</then>
<else>
<log level="custom">
<property name="message" value="continue 2"/>
</log>
<drop/>
</else>
</filter>
</inSequence>
顺便说一下,您的代码片段永远不会进入 continue 1
路由,因为您的 JSON 路径无效。
我使用的是 ESB-4.9.0 版本。
必须基于两个过滤逻辑继续 ESB 中介流。 JSON 消息在中介流中转换。目前,我正在使用两个过滤器调解器来实现这一点。 是否有可能使用单个过滤器中介来实现相同的场景?
输入JSON消息
{
"filterId": "CorrectId",
"approvalStatus": "approved",
"lifeCycleStatus": "BRANCH_READY",
"channelData": [
{
"status": "pending",
"indexId": "correctIndexId",
"description": "Test Description"
}
]
}
使用的ESB Synapse部分
<filter description="" regex="CorrectId" source="json-eval($.filterId)">
<then>
<filter description="" regex="correctIndexId" source="json-eval($.indexId)">
<then>
<!-- continue the mediation flow-1-->
</then>
<else>
<!-- continue the mediation flow-2-->
</else>
</filter>
</then>
<else>
<drop/>
</else>
</filter>
是的,这可以通过过滤器调解器和 xpath concat
函数实现:
<resource methods="POST" uri-template="/onefilter">
<inSequence>
<property name="filterId" expression="json-eval($.filterId)"/>
<property name="correctIndexId" expression="json-eval($.channelData[0].indexId)"/>
<property name="combinedID" expression="fn:concat($ctx:filterId, $ctx:correctIndexId)"/>
<filter source="$ctx:combinedID" regex="CorrectIdcorrectIndexId">
<then>
<log level="custom">
<property name="message" value="continue 1"/>
</log>
<drop/>
</then>
<else>
<log level="custom">
<property name="message" value="continue 2"/>
</log>
<drop/>
</else>
</filter>
</inSequence>
顺便说一下,您的代码片段永远不会进入 continue 1
路由,因为您的 JSON 路径无效。