Spring Integration

org.springframework.integration.jdbc
Class JdbcPollingChannelAdapter

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.jdbc.JdbcPollingChannelAdapter
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, NamedComponent, MessageSource<java.lang.Object>

public class JdbcPollingChannelAdapter
extends IntegrationObjectSupport
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.

Since:
2.0
Author:
Jonas Partner, Dave Syer

Field Summary
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Constructor Summary
JdbcPollingChannelAdapter(javax.sql.DataSource dataSource, java.lang.String selectQuery)
          Constructor taking DataSource from which the DB Connection can be obtained and the select query to execute to retrieve new rows.
JdbcPollingChannelAdapter(org.springframework.jdbc.core.JdbcOperations jdbcOperations, java.lang.String selectQuery)
          Constructor taking JdbcOperations instance to use for query execution and the select query to execute to retrieve new rows.
 
Method Summary
protected  java.util.List<?> doPoll(org.springframework.jdbc.core.namedparam.SqlParameterSource sqlQueryParameterSource)
           
 java.lang.String getComponentType()
          Subclasses may implement this method to provide component type information.
 Message<java.lang.Object> receive()
          Executes the query.
 void setMaxRowsPerPoll(int maxRows)
          The maximum number of rows to pull out of the query results per poll (if greater than zero, otherwise all rows will be packed into the outgoing message).
 void setRowMapper(org.springframework.jdbc.core.RowMapper<?> rowMapper)
           
 void setSelectSqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource sqlQueryParameterSource)
          A source of parameters for the select query used for polling.
 void setUpdatePerRow(boolean updatePerRow)
           
 void setUpdateSql(java.lang.String updateSql)
           
 void setUpdateSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)
           
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, onInit, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JdbcPollingChannelAdapter

public JdbcPollingChannelAdapter(javax.sql.DataSource dataSource,
                                 java.lang.String selectQuery)
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
selectQuery - query to execute

JdbcPollingChannelAdapter

public JdbcPollingChannelAdapter(org.springframework.jdbc.core.JdbcOperations jdbcOperations,
                                 java.lang.String selectQuery)
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 execution
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)

setUpdateSqlParameterSourceFactory

public void setUpdateSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)

setSelectSqlParameterSource

public void setSelectSqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource sqlQueryParameterSource)
A source of parameters for the select query used for polling.

Parameters:
sqlQueryParameterSource - the sql query parameter source to set

setMaxRowsPerPoll

public void setMaxRowsPerPoll(int maxRows)
The maximum number of rows to pull out of the query results per poll (if greater than zero, otherwise all rows will be packed into the outgoing message). Default is zero.

Parameters:
maxRows - the max rows to set

receive

public Message<java.lang.Object> receive()
Executes the query. If a query result set contains one or more rows, the Message payload will contain either a List of Maps for each row or, if a RowMapper has been provided, the values mapped from those rows. If the query returns no rows, this method will return null.

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

doPoll

protected java.util.List<?> doPoll(org.springframework.jdbc.core.namedparam.SqlParameterSource sqlQueryParameterSource)

getComponentType

public java.lang.String getComponentType()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this method to provide component type information.

Specified by:
getComponentType in interface NamedComponent
Overrides:
getComponentType in class IntegrationObjectSupport

Spring Integration