Mule MEL to read database result-set from an second 'database outbound endpoint'

StackOverflow https://stackoverflow.com/questions/19638524

  •  01-07-2022
  •  | 
  •  

Frage

I have a flow something like this

  1. A 'Database inbound endpoint' which polls(for every 5 mins) to mySQL Database-Server and get result-set by a select-query (automatically this becomes the current payload i.e #[message.payload])

  2. 'For each' component and a 'Logger' component in it using a expression as #[message.payload]

  3. Now flow has one more 'Database-out-bound-endpoint' component which executes another select-query and obtains result-set.

  4. 'For each' component with a 'Logger' component in it using a expression as #[message.payload]

Note: in the loggers result-set of first DB is printing. I mean second logger is also showing result-set of first query itself.Because the result-set is storing as payload

so, my questions are

  1. what is the MEL to read the result-set of second database-query in the above scenario.

  2. is there any another way to read result-set in the flow

Here is the configuration XML

<jdbc-ee:connector name="oracle_database" dataSource-ref="Oracle_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/>
    <flow name="testFileSaveFlow3" doc:name="testFileSaveFlow3">
        <poll frequency="1000" doc:name="Poll">
            <jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="selectTable1" queryTimeout="-1" connector-ref="oracle_database" doc:name="get data from table 1">
                <jdbc-ee:query key="selectTable1" value="SELECT * FROM TABLE1"/>
            </jdbc-ee:outbound-endpoint>
        </poll>
        <foreach doc:name="For Each">
            <logger message="#[message.payload]" level="INFO" doc:name="prints result-set of table1"/>
        </foreach>
        <jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="selectTable2" queryTimeout="-1" connector-ref="oracle_database" doc:name="get data from table 2">
            <jdbc-ee:query key="selectTable2" value="SELECT * FROM TABLE2"/>
        </jdbc-ee:outbound-endpoint>
        <foreach doc:name="For Each">
            <logger message="#[message.payload]" level="INFO" doc:name="prints result-set of table2"/>
        </foreach>
    </flow>

thanks in advance.

War es hilfreich?

Lösung

This is not the issue with the MEL. It is the issue with your flow logic.

The second result set is not available in the message.

The JDBC Outbound Endpoint is one-way. So Mule flow will not wait for the reply (result set) from the second JDBC (outbound ) in the middle of the flow. So the second time also it is printing the first result set.

Type 1:

Try making your JBDC outbound  request-response instead of one-way. 

Type 2:

Try Mule Enricher to call the JDBC outbound to call the DB and store the result set into a varaible and try looping the varaible.

Hope this helps.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top