nuvio
nuvio

Reputation: 2625

wso2 ESB dblookup mediator

I have a MySql db with ID,NAME,DATE I'd like to get these rows by using the dblookup mediator, seems not to be working, can anyone check my proxy definition please?

<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>

Upvotes: 2

Views: 2428

Answers (1)

Ratha
Ratha

Reputation: 9692

There is an issue, when retrieve the multiple data. If we try to retrieve multiple data, it will return the first row of data. The returned value will be stored in the synapse Messagecontext. so, if you just use the log mediator you won' be able to view the results. Use like this;

Change your sql query like this(to retrieve one row of data)

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

Then log like this;

 <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>

Upvotes: 4

Related Questions