【问题标题】:wso2 ESB dblookup mediatorwso2 ESB dblookup 中介
【发布时间】:2012-08-30 13:38:54
【问题描述】:

我有一个带有 ID、NAME、DATE 的 MySql 数据库我想通过使用 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>

【问题讨论】:

    标签: wso2 wso2esb


    【解决方案1】:

    检索多个数据时出现问题。如果我们尝试检索多个数据,它将返回第一行数据。返回的值将存储在突触消息上下文中。因此,如果您只使用日志调解器,您将能够查看结果。 像这样使用;

    像这样改变你的 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>
    

    【讨论】:

    • 酷!如何将这些值放入消息中,我应该使用 Enrich 中介吗?
    • 是使用丰富的中介..保持简单的属性中介..eg: 然后使用属性“cliExp " 丰富调解员
    • 非常感谢Ratha,我看得出来你是wso2-esb的真正专家,所以我想邀请你看看我发表的另一个问题:stackoverflow.com/questions/12157425/wso2-esb-api-management再次感谢您的支持
    猜你喜欢
    • 2012-08-31
    • 2012-08-31
    • 1970-01-01
    • 2012-08-06
    • 2012-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多