【问题标题】:How to Externalize Query in WSO2 ESB如何在 WSO2 ESB 中外部化查询
【发布时间】:2014-08-20 19:43:10
【问题描述】:

我使用 WSO2 ESB 4.8.1 创建了 ESB 代理

目前 DBLookup 中介包含以下 sql

<sql>select A, B, C from cis-dev.table1 where ... </sql>

由于 cis-dev 架构特定于开发环境,我需要将此查询存储在代理之外,以便将代理服务迁移到 QA 和 PROD 环境。

有没有办法在 WSO2 ESB 中实现这一点?

谢谢,

【问题讨论】:

    标签: wso2esb


    【解决方案1】:

    没有直接的方式将查询存储在外部并根据环境调用它。但是您可以参数化查询并随请求传递参数以更改查询中的值。请参阅下面的示例

    <dblookup>
       <connection>
           <pool>
               <driver>org.apache.derby.jdbc.ClientDriver</driver>
               <url>jdbc:derby://localhost:1527/esbdb;user=esb;password=esb</url>
               <user>esb</user>
               <password>esb</password>
           </pool>
       </connection>
       <statement>
           <sql>select * from company where name =?</sql>
           <parameter expression="//m0:getQuote/m0:request/m0:symbol"
                      xmlns:m0="http://services.samples" type="VARCHAR"/>
           <result name="company_id" column="id"/>
           <result name="company_price_0" column="price" rowIndex="2"/>
           <result name="company_price_1" column="price" rowIndex="4"/>
       </statement>
    </dblookup>
    

    【讨论】:

    • 我已经将这种方法用于 sql 参数。但是,我试图弄清楚如何外部化数据库模式,例如在我们的例子中是 cis-dev、cis-qa 和 cis-prod。如果我不能将其外部化,唯一的选择是为每个环境创建单独的汽车文件。这可能是最不受欢迎的方法,因为我们不会将相同的测试汽车文件迁移到下一个环境。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-24
    • 2017-06-29
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多