Class JdbcPollingChannelAdapter

All Implemented Interfaces:
Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, MessageSource<Object>, IntegrationPattern, NamedComponent, IntegrationInboundManagement, IntegrationManagement

public class JdbcPollingChannelAdapter extends AbstractMessageSource<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, Artem Bilan
  • Constructor Details

    • JdbcPollingChannelAdapter

      public JdbcPollingChannelAdapter(DataSource dataSource, 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 - Must not be null
      selectQuery - query to execute
    • JdbcPollingChannelAdapter

      public JdbcPollingChannelAdapter(JdbcOperations jdbcOperations, 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 Details

    • setRowMapper

      public void setRowMapper(@Nullable RowMapper<?> rowMapper)
    • setSelectQuery

      public final void setSelectQuery(String selectQuery)
      Set the select query.
      Parameters:
      selectQuery - the query.
      Since:
      5.2.1
    • setUpdateSql

      public void setUpdateSql(String updateSql)
    • setUpdatePerRow

      public void setUpdatePerRow(boolean updatePerRow)
    • setUpdateSqlParameterSourceFactory

      public void setUpdateSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)
    • setSelectSqlParameterSource

      public void setSelectSqlParameterSource(@Nullable SqlParameterSource sqlQueryParameterSource)
      A source of parameters for the select query used for polling.
      Parameters:
      sqlQueryParameterSource - the sql query parameter source to set
    • setMaxRows

      public void setMaxRows(int maxRows)
      The maximum number of rows to query. Default is zero - select all records.
      Parameters:
      maxRows - the max rows to set
      Since:
      5.1
    • onInit

      protected void onInit()
      Overrides:
      onInit in class AbstractExpressionEvaluator
    • getComponentType

      public String getComponentType()
    • doReceive

      protected Object doReceive()
      Execute the select query and the update query if provided. Returns the rows returned by the select query. If a RowMapper has been provided, the mapped results are returned.
      Specified by:
      doReceive in class AbstractMessageSource<Object>
      Returns:
      The value returned.
    • doPoll

      protected List<?> doPoll(@Nullable SqlParameterSource sqlQueryParameterSource)