Reputation: 1281
Is there a way to specify a JDBC Outbound Channel Adapter using DSL?
e.g.
<int-jdbc:outbound-channel-adapter
query="insert into foos (id, status, name) values (:headers[id], 0, :payload[foo])"
data-source="dataSource"
channel="input"/>
Also is it possible to handle parameters which may be null (e.g. if a field is null, substitute an empty string value).
Upvotes: 3
Views: 2429
Reputation: 121590
According <int-jdbc:outbound-channel-adapter>
description:
<xsd:documentation>
Configures a Consumer Endpoint for the
'org.springframework.integration.jdbc.JdbcMessageHandler' for updating a
database.
</xsd:documentation>
we have JdbcMessageHandler
which can be used as:
@Bean
public MessageHandler jdbcMessageHandler() {
JdbcMessageHandler handler = new JdbcMessageHandler(this.dataSource,
"insert into foos (id, status, name) values (:headers[id], 0, :payload[foo])");
return handler;
}
@Bean
public IntegrationFlow jdbcFlow() {
...
.handle(jdbcMessageHandler())
...
}
The null -> empty string
is possible via custom SqlParameterSourceFactory
.
Upvotes: 4