Mule:Exact usage of db:select source attribute -
Mule:Exact usage of db:select source attribute -
having flow inbound amqp connector
<flow name="flow1"> <amqp:inbound-endpoint responsetimeout="10000" exchangename="inputexchange" queuename="inputqueue" routingkey="inputqueue" connector-ref="rabbitconnector" doc:name="amqp"/> <set-variable variablename="datacount" value="0" doc:name="variable"></set-variable> <db:select config-ref="databaseconnector" target="#[flowvars.datacount]" source="#{payload[0]['count(*)']}" doc:name="select"> <db:parameterized-query><![cdata[select count(*) tablename]]></db:parameterized-query> </db:select> </flow> when no source specified datacount=[{count(*)=10}] db select returns list of map. should right value of source attribute 10 assigned datacount variable. when specifying payload[0]['count(*)'] giving error payload of byte[] payload returned amqp.
according user guide, source is:
the look used obtain value used calculate parameters. default empty, parameters calculated payload".
source used "feed" select statement parameters, not post processing results.
so remove source attribute , compute count flow variable after select with:
<set-variable variablename="selectresult" value="#[[]]" /> <db:select config-ref="databaseconnector" target="#[flowvars.selectresult]"> <db:parameterized-query><![cdata[select count(*) tablename]]></db:parameterized-query> </db:select> <set-variable variablename="datacount" value="#[flowvars.selectresult[0]['count(*)']]" /> mule mule-studio mule-component
Comments
Post a Comment