Class JdbcPollingChannelAdapter
java.lang.Object
org.springframework.integration.util.AbstractExpressionEvaluator
org.springframework.integration.endpoint.AbstractMessageSource<java.lang.Object>
org.springframework.integration.jdbc.JdbcPollingChannelAdapter
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.integration.core.MessageSource<java.lang.Object>,org.springframework.integration.IntegrationPattern,org.springframework.integration.support.context.NamedComponent,org.springframework.integration.support.management.IntegrationInboundManagement,org.springframework.integration.support.management.IntegrationManagement
public class JdbcPollingChannelAdapter
extends org.springframework.integration.endpoint.AbstractMessageSource<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
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description JdbcPollingChannelAdapter(javax.sql.DataSource dataSource, java.lang.String selectQuery)Constructor takingDataSourcefrom 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 takingJdbcOperationsinstance to use for query execution and the select query to execute to retrieve new rows. -
Method Summary
Modifier and Type Method Description protected java.util.List<?>doPoll(org.springframework.jdbc.core.namedparam.SqlParameterSource sqlQueryParameterSource)protected java.lang.ObjectdoReceive()Execute the select query and the update query if provided.java.lang.StringgetComponentType()protected voidonInit()voidsetMaxRows(int maxRows)The maximum number of rows to query.voidsetRowMapper(org.springframework.jdbc.core.RowMapper<?> rowMapper)voidsetSelectQuery(java.lang.String selectQuery)Set the select query.voidsetSelectSqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource sqlQueryParameterSource)A source of parameters for the select query used for polling.voidsetUpdatePerRow(boolean updatePerRow)voidsetUpdateSql(java.lang.String updateSql)voidsetUpdateSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)Methods inherited from class org.springframework.integration.endpoint.AbstractMessageSource
buildMessage, destroy, getBeanName, getComponentName, getManagedName, getManagedType, getOverrides, isLoggingEnabled, receive, registerMetricsCaptor, setBeanName, setHeaderExpressions, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
afterPropertiesSet, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getBeanFactory, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, setBeanFactory, setConversionServiceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
JdbcPollingChannelAdapter
public JdbcPollingChannelAdapter(javax.sql.DataSource dataSource, java.lang.String selectQuery)Constructor takingDataSourcefrom which the DB Connection can be obtained and the select query to execute to retrieve new rows.- Parameters:
dataSource- Must not be nullselectQuery- query to execute
-
JdbcPollingChannelAdapter
public JdbcPollingChannelAdapter(org.springframework.jdbc.core.JdbcOperations jdbcOperations, java.lang.String selectQuery)Constructor takingJdbcOperationsinstance to use for query execution and the select query to execute to retrieve new rows.- Parameters:
jdbcOperations- instance to use for query executionselectQuery- query to execute
-
-
Method Details
-
setRowMapper
public void setRowMapper(@Nullable org.springframework.jdbc.core.RowMapper<?> rowMapper) -
setSelectQuery
public final void setSelectQuery(java.lang.String selectQuery)Set the select query.- Parameters:
selectQuery- the query.- Since:
- 5.2.1
-
setUpdateSql
public void setUpdateSql(java.lang.String updateSql) -
setUpdatePerRow
public void setUpdatePerRow(boolean updatePerRow) -
setUpdateSqlParameterSourceFactory
public void setUpdateSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory) -
setSelectSqlParameterSource
public void setSelectSqlParameterSource(@Nullable 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
-
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:
onInitin classorg.springframework.integration.util.AbstractExpressionEvaluator
-
getComponentType
public java.lang.String getComponentType() -
doReceive
protected java.lang.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:
doReceivein classorg.springframework.integration.endpoint.AbstractMessageSource<java.lang.Object>
-
doPoll
protected java.util.List<?> doPoll(@Nullable org.springframework.jdbc.core.namedparam.SqlParameterSource sqlQueryParameterSource)
-