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(java.lang.Object obj,
boolean keysGenerated) |
java.lang.String |
getComponentType() |
protected void |
handleMessageInternal(org.springframework.messaging.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) |
getOrder, handleMessage, setOrder, setShouldTrack
afterPropertiesSet, getApplicationContext, getApplicationContextId, getBeanFactory, getComponentName, getConversionService, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, onInit, setApplicationContext, setBeanFactory, setBeanName, setComponentName, setConversionService, setMessageBuilderFactory, setTaskScheduler, toString
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)
public java.lang.String getComponentType()
getComponentType
in interface org.springframework.integration.support.context.NamedComponent
getComponentType
in class org.springframework.integration.handler.AbstractMessageHandler
protected void handleMessageInternal(org.springframework.messaging.Message<?> message) throws org.springframework.integration.MessageRejectedException, org.springframework.messaging.MessageHandlingException, org.springframework.messaging.MessageDeliveryException
SqlParameterSourceFactory
.handleMessageInternal
in class org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.MessageRejectedException
org.springframework.messaging.MessageHandlingException
org.springframework.messaging.MessageDeliveryException
protected java.util.List<? extends java.util.Map<java.lang.String,java.lang.Object>> executeUpdateQuery(java.lang.Object obj, boolean keysGenerated)