public class JdbcMessageHandler
extends org.springframework.integration.handler.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)| 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(org.springframework.messaging.Message<?> message,
boolean keysGenerated) |
java.lang.String |
getComponentType() |
protected void |
handleMessageInternal(org.springframework.messaging.Message<?> message)
Executes the update, passing the message into the
SqlParameterSourceFactory. |
protected void |
onInit() |
void |
setKeysGenerated(boolean keysGenerated)
Flag to indicate that the update query is an insert with auto-generated keys,
which will be logged at debug level.
|
void |
setPreparedStatementSetter(MessagePreparedStatementSetter preparedStatementSetter)
Specify a
MessagePreparedStatementSetter to populate parameters on the
PreparedStatement with the Message context. |
void |
setSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory) |
void |
setUpdateSql(java.lang.String updateSql) |
configureMetrics, getActiveCount, getActiveCountLong, getDuration, getErrorCount, getErrorCountLong, getHandleCount, getHandleCountLong, getManagedName, getManagedType, getMaxDuration, getMeanDuration, getMinDuration, getOrder, getStandardDeviationDuration, handleMessage, isCountsEnabled, isLoggingEnabled, isStatsEnabled, onComplete, onError, onNext, onSubscribe, reset, setCountsEnabled, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, setStatsEnabledafterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringpublic 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)
public void setPreparedStatementSetter(MessagePreparedStatementSetter preparedStatementSetter)
MessagePreparedStatementSetter to populate parameters on the
PreparedStatement with the Message context.
This is a low-level alternative to the SqlParameterSourceFactory.
preparedStatementSetter - the MessagePreparedStatementSetter to set.public java.lang.String getComponentType()
getComponentType in interface org.springframework.integration.support.context.NamedComponentgetComponentType in class org.springframework.integration.handler.AbstractMessageHandlerprotected void onInit()
throws java.lang.Exception
onInit in class org.springframework.integration.handler.AbstractMessageHandlerjava.lang.Exceptionprotected void handleMessageInternal(org.springframework.messaging.Message<?> message)
throws java.lang.Exception
SqlParameterSourceFactory.handleMessageInternal in class org.springframework.integration.handler.AbstractMessageHandlerjava.lang.Exceptionprotected java.util.List<? extends java.util.Map<java.lang.String,java.lang.Object>> executeUpdateQuery(org.springframework.messaging.Message<?> message,
boolean keysGenerated)