Reputation: 12459
I would like to read some email details from the DB, and here's what my connector looks like:
<jdbc:connector name="dbConnector" dataSource-ref="dataSource">
<jdbc:query key="sqlQuery"
value="SELECT from, to, subject, body FROM email WHERE status='PENDING'" />
<jdbc:query key="sqlQuery.ack"
value="UPDATE email SET status='IN PROGRESS' WHERE id=#[map-payload:id]" />
</jdbc:connector>
I would then like to use those details to send a bunch of mails. I expect that the inbound-endpoint will be the JDBC Connector and the outbound-endpoint will be SMTP Connector, but I don't know how to store and use data I read from that table. Is there a way to do this without resorting to Java code?
Upvotes: 1
Views: 925
Reputation: 33413
Using transformers should be enough to achieve your goal: the inbound JDBC endpoint will give you a Map payload. From this payload you will extract the properties required by the outbound SMTP endpoint and the body of the message:
<!-- Set SMTP endpoint properties -->
<message-properties-transformer>
<add-message-property key="subject" value="#[map-payload:subject]"/>
...
</message-properties-transformer>
<!-- Set the message Body as new payload -->
<expression-transformer>
<return-argument evaluator="map-payload" expression="body"/>
</expression-transformer>
Upvotes: 1