org.springframework.integration.jdbc
Class JdbcMessageHandler
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.jdbc.JdbcMessageHandler
- All Implemented Interfaces:
- BeanFactoryAware, BeanNameAware, InitializingBean, Ordered, NamedComponent, MessageHandler, TrackableComponent
public class JdbcMessageHandler
- extends AbstractMessageHandler
A message handler that executes an SQL update. Dynamic query parameters are supported through the
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
)
- Since:
- 2.0
- Author:
- Dave Syer
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getRequiredMetadataPersister, getTaskScheduler, onInit, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString |
JdbcMessageHandler
public JdbcMessageHandler(DataSource dataSource,
String updateSql)
- Constructor taking
DataSource
from which the DB Connection can be obtained and the select query to
execute to retrieve new rows.
- Parameters:
dataSource
- used to create a SimpleJdbcTemplate
updateSql
- query to execute
JdbcMessageHandler
public JdbcMessageHandler(JdbcOperations jdbcOperations,
String updateSql)
- Constructor taking
JdbcOperations
instance to use for query execution and the select query to execute to
retrieve new rows.
- Parameters:
jdbcOperations
- instance to use for query executionupdateSql
- query to execute
setKeysGenerated
public void setKeysGenerated(boolean keysGenerated)
- Flag to indicate that the update query is an insert with autogenerated keys, which will be logged at debug level.
- Parameters:
keysGenerated
- the flag value to set
setUpdateSql
public void setUpdateSql(String updateSql)
setSqlParameterSourceFactory
public void setSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)
handleMessageInternal
protected void handleMessageInternal(Message<?> message)
throws MessageRejectedException,
MessageHandlingException,
MessageDeliveryException
- Executes the update, passing the message into the
SqlParameterSourceFactory
.
- Specified by:
handleMessageInternal
in class AbstractMessageHandler
- Throws:
MessageRejectedException
MessageHandlingException
MessageDeliveryException
executeUpdateQuery
protected List<? extends Map<String,Object>> executeUpdateQuery(Object obj,
boolean keysGenerated)
Copyright © 2010. All Rights Reserved.