How to make the URL value in the DBLookup Mediator dynamic using a property in WSO2 Developer Studio?

41 views Asked by At

I am currently working on a project using WSO2 Developer Studio and facing a challenge in trying to make the URL value in the DBLookup Mediator dynamic. I need to configure the DBLookup to access an external database, and the URL value must be dynamically fed through a property.

I've tried the following two ways but it doesn't work as expected:

[1]

<property name="database.url" expression="json-eval($.url)" scope="default" type="STRING"/>

<dblookup>
    <connection>
        <pool>
            <driver>oracle.jdbc.OracleDriver</driver>
            <url expression="get-property('database.url')"/>
            <user>test</user>
            <password>12345</password>
        </pool>
    </connection>
</dblookup>

[2]

<property name="database.url" expression="json-eval($.url)" scope="default" type="STRING"/>

<dblookup>
    <connection>
        <pool>
            <driver>oracle.jdbc.OracleDriver</driver>
            <url>{get-property('database.url')}</url>
            <user>test</user>
            <password>12345</password>
        </pool>
    </connection>
</dblookup>
1

There are 1 answers

1
tizu918347 On

HTTP endpoints can be dynamically constructed using uri template. Create properties name starting with uri.var prefix and define the uri template to refer those created properties e.g if property name is uri.var.context then uri template cane be defined as http:://localhost/{uri.var.context}

Try this:

<property name="uri.var.database" expression="json-eval($.url)" scope="default" type="STRING"/>

<dblookup>
<connection>
    <pool>
        <driver>oracle.jdbc.OracleDriver</driver>
        <url>{uri.var.database}</url>
        <user>test</user>
        <password>12345</password>
    </pool>
</connection>

There are more use-cases here: https://medium.com/@Jenananthan/wso2-esb-construct-dynamic-urls-67fad2f6d34c