Class JdbcPollingChannelAdapter
java.lang.Object
org.springframework.integration.util.AbstractExpressionEvaluator
org.springframework.integration.endpoint.AbstractMessageSource<Object>
org.springframework.integration.jdbc.JdbcPollingChannelAdapter
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,MessageSource<Object>
,IntegrationPattern
,NamedComponent
,IntegrationInboundManagement
,IntegrationManagement
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
-
Constructor Summary
ConstructorDescriptionJdbcPollingChannelAdapter
(DataSource dataSource, String selectQuery) Constructor takingDataSource
from which the DB Connection can be obtained and the select query to execute to retrieve new rows.JdbcPollingChannelAdapter
(JdbcOperations jdbcOperations, String selectQuery) Constructor takingJdbcOperations
instance to use for query execution and the select query to execute to retrieve new rows. -
Method Summary
Modifier and TypeMethodDescriptionprotected List<?>
doPoll
(SqlParameterSource sqlQueryParameterSource) Perform a select against providedSqlParameterSource
.protected Object
Execute the select query and the update query if provided.protected void
onInit()
void
setMaxRows
(int maxRows) The maximum number of rows to query.void
setRowMapper
(RowMapper<?> rowMapper) Set aRowMapper
.final void
setSelectQuery
(String selectQuery) Set the select query.void
setSelectSqlParameterSource
(SqlParameterSource sqlQueryParameterSource) A source of parameters for the select query used for polling.void
setUpdatePerRow
(boolean updatePerRow) Set a flag to update per record or not.void
setUpdateSql
(String updateSql) Set an update query.void
setUpdateSqlParameterSourceFactory
(SqlParameterSourceFactory sqlParameterSourceFactory) Set anSqlParameterSourceFactory
for update query.Methods inherited from class org.springframework.integration.endpoint.AbstractMessageSource
buildMessage, destroy, getBeanName, getComponentName, getManagedName, getManagedType, getOverrides, isLoggingEnabled, receive, registerMetricsCaptor, setBeanName, setHeaderExpressions, setLoggingEnabled, setManagedName, setManagedType
Methods inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
afterPropertiesSet, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getBeanFactory, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, setBeanFactory, setConversionService, setSimpleEvaluationContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs, isObserved, registerObservationRegistry
Methods inherited from interface org.springframework.integration.core.MessageSource
getIntegrationPatternType
-
Constructor Details
-
JdbcPollingChannelAdapter
Constructor takingDataSource
from 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
Constructor takingJdbcOperations
instance 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
Set aRowMapper
.- Parameters:
rowMapper
- theRowMapper
to use.
-
setSelectQuery
Set the select query.- Parameters:
selectQuery
- the query.- Since:
- 5.2.1
-
setUpdateSql
Set an update query.- Parameters:
updateSql
- the update query to use.
-
setUpdatePerRow
public void setUpdatePerRow(boolean updatePerRow) Set a flag to update per record or not. Defaults to false.- Parameters:
updatePerRow
- the flag to control an update per record or whole batch.
-
setUpdateSqlParameterSourceFactory
Set anSqlParameterSourceFactory
for update query.- Parameters:
sqlParameterSourceFactory
- theSqlParameterSourceFactory
to use.
-
setSelectSqlParameterSource
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 classAbstractExpressionEvaluator
-
getComponentType
-
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 classAbstractMessageSource<Object>
- Returns:
- The value returned.
-
doPoll
Perform a select against providedSqlParameterSource
.- Parameters:
sqlQueryParameterSource
- theSqlParameterSource
to use. Optional.- Returns:
- the result of the query.
-