Frage

As of now ,when I poll the database with a query,It will fetch me multiple records during a specified duration.Problem is ,these multiple records will be pushed as a single message into the queue.How do I push every record from the set of records as an individual message?

War es hilfreich?

Lösung

As you have explained the JDBC endpoint is fetching a collection of records and sending them as one single message to the queue. Solution for this is two options.

  1. Using Mule's For-Each message processor. This helps in iterating through the collection object and processes each item as one message.
  2. Using Mule's collection splitter to iterate through the collection of records.

Solution for option 1 looks like as shown in the image below.

JDBC For Each JMS flow

The code for this flow loks like this.

<flow name="JDBC-For-Each-JMS-Flow" >
    <jdbc-ee:inbound-endpoint queryKey="SelectAll" mimeType="text/javascript"  queryTimeout="500000" pollingFrequency="1000" doc:name="Database">           
        <jdbc-ee:query key="SelectAll" value="select * from users"/>            
    </jdbc-ee:inbound-endpoint>
    <foreach doc:name="For Each" collection="#[payload]" >
        <jms:outbound-endpoint doc:name="JMS"/>
    </foreach>
    <catch-exception-strategy doc:name="Catch Exception Strategy"/>
</flow>

Note: This is a sample flow.

Hope this helps.

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