2012-08-30 102 views
1

我有一個ID,名稱,日期的MySql數據庫我想通過使用dblookup調解器來獲得這些行,似乎沒有工作,任何人都可以檢查我的代理定義嗎?wso2 ESB dblookup調解器

<proxy xmlns="http://ws.apache.org/ns/synapse" name="Database" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> 
    <target> 
     <inSequence> 
     <dblookup> 
      <connection> 
       <pool> 
        <password>1234</password> 
        <user>root</user> 
        <url>jdbc:mysql://localhost:3306/new_db</url> 
        <driver>com.mysql.jdbc.Driver</driver> 
       </pool> 
      </connection> 
      <statement> 
       <sql>select * from users where name=?</sql> 
       <result name="client_expiration" column="expiration" /> 
       <result name="client_id" column="id" /> 
       <result name="client_name" column="name" /> 
      </statement> 
     </dblookup> 
     <log /> 
     </inSequence> 
    </target> 
</proxy> 

回答

3

檢索多個數據時存在問題。如果我們嘗試檢索多個數據,它將返回第一行數據。返回值將存儲在突觸Messagecontext中。所以,如果你只是使用日誌中介,你就能夠查看結果。 像這樣使用;

更改您的SQL查詢像這樣(檢索數據的一行)

<sql>select * from users where name=ABC</sql> 

然後登錄這樣的;

<log level="custom"> 
    <property name="returned value for client_expiration is : "  expression="get-property('client_expiration')"/> 
    <property name="returned value for client_id is : "  expression="get-property('client_id')"/> 
    <property name="returned value for client_name is : "  expression="get-property('client_name')"/> 
</log> 
+0

很酷!如何將這些值放入消息中,我應該使用Enrich中介嗎? – nuvio

+1

是使用補充mediator..Keep簡單的財產mediator..eg:然後使用富媒體中的屬性「cliExp」 – Ratha

+0

謝謝很多Ratha,我可以看到你是wso2-esb的真正專家,所以我想請你看看我發表的另一個問題:http://stackoverflow.com/questions/12157425/wso2-esb-api -management 非常感謝您的支持 – nuvio