org.springframework.integration.jdbc
Class JdbcPollingChannelAdapter

java.lang.Object
  extended by org.springframework.integration.jdbc.JdbcPollingChannelAdapter
All Implemented Interfaces:
MessageSource<java.lang.Object>

public class JdbcPollingChannelAdapter
extends java.lang.Object
implements MessageSource<java.lang.Object>

A polling channel adapter that creates messages from the payload returned by executing a select query Optionally an update can be executed after the select in order to update processed rows

Author:
Jonas Partner

Constructor Summary
JdbcPollingChannelAdapter(javax.sql.DataSource dataSource, java.lang.String selectQuery)
          Constructor taking query to execute to retreive new rows and DataSource from which the DB Connection can be obtained
JdbcPollingChannelAdapter(org.springframework.jdbc.core.simple.SimpleJdbcOperations jdbcOperations, java.lang.String selectQuery)
          Constructor taking query to execute on a poll and SimpleJdbcOperations instance to use for query execution
 
Method Summary
protected  void executeUpdateQuery(java.lang.Object obj)
           
protected  java.lang.Object pollAndUpdate()
          Execute the select query and the update query if provided and rows are returned by the select query
protected  java.util.List pollWithRowMapper()
           
 Message<java.lang.Object> receive()
          Polls for new rows returning a message containing one or more rows where rows are found and null where no rows are returned by the select query
 void setRowMapper(org.springframework.jdbc.core.RowMapper<?> rowMapper)
           
 void setSqlParameterSourceFactoryForUpdate(SqlParamterSourceFactory sqlParameterSourceFactoryForUpdate)
           
 void setUpdatePerRow(boolean updatePerRow)
           
 void setUpdateSql(java.lang.String updateSql)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcPollingChannelAdapter

public JdbcPollingChannelAdapter(javax.sql.DataSource dataSource,
                                 java.lang.String selectQuery)
Constructor taking query to execute to retreive new rows and DataSource from which the DB Connection can be obtained

Parameters:
dataSource - used to create a SimpleJdbcTemplate
selectQuery - query to execute

JdbcPollingChannelAdapter

public JdbcPollingChannelAdapter(org.springframework.jdbc.core.simple.SimpleJdbcOperations jdbcOperations,
                                 java.lang.String selectQuery)
Constructor taking query to execute on a poll and SimpleJdbcOperations instance to use for query execution

Parameters:
jdbcOperations -
selectQuery - query to execute
Method Detail

setRowMapper

public void setRowMapper(org.springframework.jdbc.core.RowMapper<?> rowMapper)

setUpdateSql

public void setUpdateSql(java.lang.String updateSql)

setUpdatePerRow

public void setUpdatePerRow(boolean updatePerRow)

setSqlParameterSourceFactoryForUpdate

public void setSqlParameterSourceFactoryForUpdate(SqlParamterSourceFactory sqlParameterSourceFactoryForUpdate)

receive

public Message<java.lang.Object> receive()
Polls for new rows returning a message containing one or more rows where rows are found and null where no rows are returned by the select query

Specified by:
receive in interface MessageSource<java.lang.Object>

pollAndUpdate

protected java.lang.Object pollAndUpdate()
Execute the select query and the update query if provided and rows are returned by the select query

Returns:

executeUpdateQuery

protected void executeUpdateQuery(java.lang.Object obj)

pollWithRowMapper

protected java.util.List pollWithRowMapper()