JDBC Support
- Spring Integration provides Channel Adapters for receiving and sending
- messages via database queries.
+
+ Spring Integration provides Channel Adapters for receiving and sending
+ messages via database queries. Through those adapters Spring Integration
+ supports not only plain JDBC SQL Queries, but also Stored Procedure and
+ Stored Function calls.
+
+
+ The following JDBC components are available by default:
+
+
+
+ Inbound Channel Adapter
+
+
+ Outbound Channel Adapter
+
+
+ Outbound Gateway
+
+
+ Stored Procedure Inbound Channel Adapter
+
+
+ Stored Procedure Outbound Channel Adapter
+
+
+ Stored Procedure Outbound Gateway
+
+
+
+ Furthermore, the Spring Integration JDBC Module also provides a
+ JDBC Message Store
+ Inbound Channel Adapter
@@ -83,29 +114,77 @@
is to handle a message and use it to execute a SQL query. The message
payload and headers are available by default as input parameters to the
query, for instance:
-
+
+
]]>
- In the example above, messages arriving on the channel "input" have a payload of
- a map with key "foo", so the [] operator dereferences that
- value from the map. The headers are also accessed as a map.
- The parameters in the query above are bean property expressions on the incoming message (not Spring EL expressions). This behavior is part of the
+
+ In the example above, messages arriving on the channel labelled
+ input have a payload of a map with key
+ foo, so the [] operator dereferences
+ that value from the map. The headers are also accessed as a map.
+
+
+
+ The parameters in the query above are bean property expressions on the
+ incoming message (not Spring EL expressions). This behavior is part of the
SqlParameterSource
- which is the default source created by the outbound adapter. Other behavior is possible in the adapter, and requires the user to inject a different
- SqlParameterSourceFactory.
-
+ which is the default source created by the outbound adapter. Other
+ behavior is possible in the adapter, and requires the user to inject a
+ different SqlParameterSourceFactory.
+
- The outbound adapter requires a reference to either a DataSource or
- a JdbcTemplate. It can also have a
- SqlParameterSourceFactory injected to control the
- binding of incoming message to the query.
+
+ The outbound adapter requires a reference to either a
+ DataSource or a
+ JdbcTemplate. It can also have a
+ SqlParameterSourceFactory injected to control
+ the binding of each incoming message to a query.
+
- If the input channel is a direct channel then the outbound adapter
- runs its query in the same thread, and therefore the same transaction (if
- there is one) as the sender of the message.
+
+ If the input channel is a direct channel, then the outbound adapter runs
+ its query in the same thread, and therefore the same transaction (if
+ there is one) as the sender of the message.
+
+
+ Passing Parameters using SpEL Expressions
+
+
+ A common requirement for most JDBC Channel Adapters is to pass parameters
+ as part of Sql queries or Stored Procedures/Functions. As mentioned above,
+ these parameters are by default bean property expressions, not SpEL expressions.
+
+ However, if you need to pass SpEL expression as parameters, you must inject
+ a SqlParameterSourceFactory explicitly.
+
+
+ The following example uses a ExpressionEvaluatingSqlParameterSourceFactory
+ to achieve that requirement.
+
+
+
+
+
+
+
+
+]]>
+
+ For further information, please also see
+
+
@@ -510,7 +589,7 @@
poller
Allows you to configure a Message Poller if this endpoint is a
- PollingConsumer
+ PollingConsumer.
Optional.