简体   繁体   English

如何比较wso2 esb中过滤器中介的整数属性?

[英]how to compare integer properties in filter mediation in wso2 esb?

i am new in wso2 esb and define 3 service that return integer value and use filter mediator to rout from one to another , but not correct work and in filter mode always return false my source is : 我是wso2 esb的新手,并定义了3个返回整数值的服务,并使用filter mediator从一个到另一个路由,但不正确的工作,在过滤模式下总是返回false我的源是:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="SeqOne">
<log level="full"/>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:m0="http://tempuri.org/"        name="CParam" expression="//m0:SumSerViseResponse/m0:SumSerViseResult" scope="default"   type="INTEGER"/>
<log level="custom">
  <property xmlns:ns="http://org.apache.synapse/xsd" name="CParam"  expression="$ctx:CParam"/>
</log>
<property name="propertyA" value="4" scope="default" type="INTEGER"/>
<log level="custom">
  <property xmlns:ns="http://org.apache.synapse/xsd" name="propertyA" expression="get-property('propertyA')"/>
</log>
<property xmlns:ns="http://org.apache.synapse/xsd" name="propertyCompare" expression="$ctx:CParam > get-property('propertyA')" type="STRING"/>
<log level="custom">
  <property xmlns:ns="http://org.apache.synapse/xsd" name="propertyCompare" expression="get-property('propertyCompare')"/>
</log>
<filter xmlns:ns="http://org.apache.synapse/xsd" source="get-property('propertyCompare')" regex="true">
  <then>

I tried your scenario and got the same output as yours. 我尝试了你的场景并获得了与你相同的输出。 Then looked deep into it as this was a basic functionality and as I thought I've done something similar before. 然后仔细研究它,因为这是一个基本的功能,因为我以前做过类似的事情。

The issue here is in the type of the property. 这里的问题是属性的类型。 For some strange reason INTEGER does not work here. 出于某些奇怪的原因, INTEGER在这里不起作用。 You need to have DOUBLE or STRING . 你需要有DOUBLESTRING Even if you have string, it will correctly cast it when you do a comparison as in here. 即使你有字符串,它也会在你进行比较时正确地投射它。 The following worked for me. 以下对我有用。

<inSequence>
     <log level="full"/>
     <property xmlns:m0="http://tempuri.org/"
               name="CParam"
               expression="//m0:SumSerViseResponse/m0:SumSerViseResult"
               scope="default"
               type="DOUBLE"/>
     <log level="custom">
        <property name="CParam" expression="$ctx:CParam"/>
     </log>
     <property name="propertyA" value="4.0" scope="default" type="DOUBLE"/>
     <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd"
                  name="propertyA"
                  expression="get-property('propertyA')"/>
     </log>
     <property name="propertyCompare"
               expression="$ctx:CParam > get-property('propertyA')"
               scope="default"
               type="BOOLEAN"/>
     <log level="custom">
        <property name="propertyCompare" expression="get-property('propertyCompare')"/>
     </log>
     <filter xpath="$ctx:CParam > get-property('propertyA')">
        <then>
           <send>
              <endpoint>
                 <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
              </endpoint>
           </send>
        </then>
        <else>
           <drop/>
        </else>
     </filter>
  </inSequence>

following is an example done with switch mediator, 以下是使用switch mediator完成的示例,

<switch source="get-property('propertyCompare')">
        <case regex="1">
           <log>
              <property name="one" value="__________ONE__________"/>
           </log>
        </case>
        <case regex="2">
           <log>
              <property name="two" value="__________TWO__________"/>
           </log>
        </case>
     </switch>

replace the log mediators with send mediator according to your needs. 根据您的需要用send mediator替换日志调解器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 wso2 ESB 中对多个参数使用过滤器 - How to use filter for more than one parameter in wso2 ESB WSO2 4.8.0 ESB条件路由器 - WSO2 4.8.0 ESB conditional router 如何比较和过滤2个数组 - How to compare and filter 2 arrays 在Biztalk Server管理控制台的“发送端口”属性下找不到Microsoft.Practices.ESB.Itinerary筛选器 - Unable to find Microsoft.Practices.ESB.Itinerary filter under Send Port properties in Biztalk Server Administration Console Mule ESB:如何根据主题或发件人过滤电子邮件? - Mule ESB: how to filter emails based on subject or sender? 如何过滤一个类的属性集合? - How to filter a class properties collection? 如何使用Filter将recycList与recyclerview中的filterList进行比较? - How to compare originalList to filterList in recyclerview using Filter? 如何过滤数组并将其与Javascript中的函数参数进行比较? - How to filter an array and compare it with the function arguments in Javascript? 为什么当表达式返回 integer 时,过滤器会尝试比较字符串和 int32 数据类型? - Why is the filter trying to compare a string and int32 data types when expressions return an integer? 如何在过滤器中加载属性文件 - How to load properties files inside a filter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM