public class JdbcMessageHandler extends AbstractMessageHandler
SqlParameterSourceFactory
abstraction, the default implementation of which wraps the message so that its bean
properties can be referred to by name in the query string E.g.
INSERT INTO FOOS (MESSAGE_ID, PAYLOAD) VALUES (:headers[id], :payload)N.B. do not use quotes to escape the header keys. The default SQL parameter source (from Spring JDBC) can also handle headers with dotted names (e.g.
business.id
)logger
Constructor and Description |
---|
JdbcMessageHandler(javax.sql.DataSource dataSource,
java.lang.String updateSql)
Constructor taking
DataSource from which the DB Connection can be obtained and the select query to
execute to retrieve new rows. |
JdbcMessageHandler(org.springframework.jdbc.core.JdbcOperations jdbcOperations,
java.lang.String updateSql)
Constructor taking
JdbcOperations instance to use for query execution and the select query to execute to
retrieve new rows. |
Modifier and Type | Method and Description |
---|---|
protected java.util.List<? extends java.util.Map<java.lang.String,java.lang.Object>> |
executeUpdateQuery(java.lang.Object obj,
boolean keysGenerated) |
protected void |
handleMessageInternal(Message<?> message)
Executes the update, passing the message into the
SqlParameterSourceFactory . |
void |
setKeysGenerated(boolean keysGenerated)
Flag to indicate that the update query is an insert with autogenerated keys, which will be logged at debug level.
|
void |
setSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory) |
void |
setUpdateSql(java.lang.String updateSql) |
getComponentType, getOrder, handleMessage, setOrder, setShouldTrack
afterPropertiesSet, getApplicationContextId, getBeanFactory, getComponentName, getConversionService, getIntegrationProperties, getIntegrationProperty, getTaskScheduler, onInit, setApplicationContext, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getComponentName
public JdbcMessageHandler(javax.sql.DataSource dataSource, java.lang.String updateSql)
DataSource
from which the DB Connection can be obtained and the select query to
execute to retrieve new rows.dataSource
- Must not be nullupdateSql
- query to executepublic JdbcMessageHandler(org.springframework.jdbc.core.JdbcOperations jdbcOperations, java.lang.String updateSql)
JdbcOperations
instance to use for query execution and the select query to execute to
retrieve new rows.jdbcOperations
- instance to use for query executionupdateSql
- query to executepublic void setKeysGenerated(boolean keysGenerated)
keysGenerated
- the flag value to setpublic void setUpdateSql(java.lang.String updateSql)
public void setSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)
protected void handleMessageInternal(Message<?> message) throws MessageRejectedException, MessageHandlingException, MessageDeliveryException
SqlParameterSourceFactory
.handleMessageInternal
in class AbstractMessageHandler
MessageRejectedException
MessageHandlingException
MessageDeliveryException
protected java.util.List<? extends java.util.Map<java.lang.String,java.lang.Object>> executeUpdateQuery(java.lang.Object obj, boolean keysGenerated)