注册。 wso2 esb 中的条件路由器

Regd. Conditional Router in wso2 esb

我正在 wso2 esb 中的条件路由器上工作,我的场景如下。 我在 payload 中提取了 studentno 并想在其之上执行条件路由器,但这适用于 header 和查询参数,而不适用于查询变量或从 payload 中提取的值。我尝试了解决方案,但得到了 switch-case 作为解决方案。这是仅适用于 header 和参数的条件路由器的限制吗?如果否,请在条件路由器中提供您对条件的输入。

提前致谢。

有两种类型可以满足您的要求。您应该能够使用 soap [2] 类型或 属性 [1] 类型来根据负载进行路由内容。请参阅下面的示例。其他可用类型可以在文档 [3] 中找到。

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="conditionalRouter"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <property expression="$body//symbol" name="requestProperty"/>
         <log level="custom">
            <property expression="$body//symbol" name="requestProperty"/>
         </log>
         <conditionalRouter continueAfter="false">
            <conditionalRoute breakRoute="false">
               <condition>
                  <match regex="WSO2.*" source="//symbol" type="soap"/>
               </condition>
               <target sequence="cnd1_seq"/>
            </conditionalRoute>
            <conditionalRoute breakRoute="false">
               <condition>
                  <match regex="IBM.*" source="requestProperty" type="property"/>
               </condition>
               <target sequence="cnd2_seq"/>
            </conditionalRoute>
         </conditionalRouter>
      </inSequence>
   </target>
   <description/>
</proxy>
                            

请求 1

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
        <request>
            <symbol>WSO2</symbol>
        </request>
</soapenv:Body>
</soapenv:Envelope>

请求 2

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
        <request>
            <symbol>WSO2</symbol>
        </request>
</soapenv:Body>
</soapenv:Envelope>

备注

条件路由器调解器 已从 EI 6.5.0 版本中删除 [4]。因此,如果您已经使用 switch case 中介开发了中介,最好使用它,因为如果您决定迁移到新的 EI 版本,它对您来说会更容易。

[1]-https://github.com/wso2/wso2-synapse/blob/v2.1.7-wso2v111/modules/commons/src/main/java/org/apache/synapse/commons/evaluators/config/TextProcessingEvaluatorFactory.java#L60

[2]-https://github.com/wso2/wso2-synapse/blob/v2.1.7-wso2v111/modules/commons/src/main/java/org/apache/synapse/commons/evaluators/config/TextProcessingEvaluatorFactory.java#L66

[3]-https://docs.wso2.com/display/EI620/Sample+157%3A+Conditional+Router+for+Routing+Messages+based+on+HTTP+URL%2C+ HTTP+Headers+and+查询+参数

[4]-https://docs.wso2.com/display/EI650/About+this+Release