Class R2dbcMessageSource
java.lang.Object
org.springframework.integration.util.AbstractExpressionEvaluator
org.springframework.integration.endpoint.AbstractMessageSource<org.reactivestreams.Publisher<?>>
org.springframework.integration.r2dbc.inbound.R2dbcMessageSource
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- MessageSource<org.reactivestreams.Publisher<?>>,- IntegrationPattern,- NamedComponent,- IntegrationInboundManagement,- IntegrationManagement
An instance of 
MessageSource which returns
 a Message with a payload which is the result of
 execution of query. When expectSingleResult is false (default), the R2DBC
 query is executed returning a Flux.
 The returned Flux will be used as the payload of the
 Message returned by the AbstractMessageSource.receive()
 method.
 
 When expectSingleResult is true, the query is executed returning a Mono
 for the single object returned from the query.
- Since:
- 5.4
- Author:
- Rohan Mukesh, Artem Bilan
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionclassAn instance of this class is used as a root object for query expression to give a limited access only to theStatementMapper.createSelect(java.lang.String)fluent API.Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.util.AbstractExpressionEvaluatorEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
- 
Constructor SummaryConstructorsConstructorDescriptionR2dbcMessageSource(org.springframework.data.r2dbc.core.R2dbcEntityOperations r2dbcEntityOperations, String query) Create an instance with the providedR2dbcEntityOperationsand SpEL expression which should resolve to a Relational 'query' string.R2dbcMessageSource(org.springframework.data.r2dbc.core.R2dbcEntityOperations r2dbcEntityOperations, Expression queryExpression) Create an instance with the providedR2dbcEntityOperationsand SpEL expression which should resolve to a query string orStatementMapper.SelectSpecinstance.
- 
Method SummaryModifier and TypeMethodDescriptionprotected ObjectExecute a query returning its results as the Message payload.protected voidonInit()voidsetBindFunction(BiFunction<DatabaseClient.GenericExecuteSpec, ?, DatabaseClient.GenericExecuteSpec> bindFunction) Set aBiFunctionwhich is used to bind parameters into the update query.voidsetExpectSingleResult(boolean expectSingleResult) The flag to manage which find* method to invoke onR2dbcEntityOperations.voidsetPayloadType(Class<?> payloadType) Set the type of the entityClass which is used for theEntityRowMapper.voidsetUpdateSql(String updateSql) Set an update query that will be passed to theDatabaseClient.sql(String)method.Methods inherited from class org.springframework.integration.endpoint.AbstractMessageSourcebuildMessage, destroy, getBeanName, getComponentName, getManagedName, getManagedType, getOverrides, isLoggingEnabled, receive, registerMetricsCaptor, setBeanName, setHeaderExpressions, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from class org.springframework.integration.util.AbstractExpressionEvaluatorafterPropertiesSet, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getBeanFactory, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, setBeanFactory, setConversionServiceMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAs, isObserved, registerObservationRegistryMethods inherited from interface org.springframework.integration.core.MessageSourcegetIntegrationPatternType
- 
Constructor Details- 
R2dbcMessageSourcepublic R2dbcMessageSource(org.springframework.data.r2dbc.core.R2dbcEntityOperations r2dbcEntityOperations, String query) Create an instance with the providedR2dbcEntityOperationsand SpEL expression which should resolve to a Relational 'query' string. It assumes that theR2dbcEntityOperationsis fully initialized and ready to be used. The 'query' will be evaluated on every call to theAbstractMessageSource.receive()method.- Parameters:
- r2dbcEntityOperations- The reactive database client for performing database calls.
- query- The query String.
 
- 
R2dbcMessageSourcepublic R2dbcMessageSource(org.springframework.data.r2dbc.core.R2dbcEntityOperations r2dbcEntityOperations, Expression queryExpression) Create an instance with the providedR2dbcEntityOperationsand SpEL expression which should resolve to a query string orStatementMapper.SelectSpecinstance. It assumes that theR2dbcEntityOperationsis fully initialized and ready to be used. The 'queryExpression' will be evaluated on every call to theAbstractMessageSource.receive()method.- Parameters:
- r2dbcEntityOperations- The reactive for performing database calls.
- queryExpression- The query expression. The root object for evaluation context is a- R2dbcMessageSource.SelectCreatorfor delegation int the- StatementMapper.createSelect(java.lang.String)fluent API.
 
 
- 
- 
Method Details- 
setPayloadTypeSet the type of the entityClass which is used for theEntityRowMapper.- Parameters:
- payloadType- The class to use.
 
- 
setUpdateSqlSet an update query that will be passed to theDatabaseClient.sql(String)method.- Parameters:
- updateSql- the update query string.
 
- 
setBindFunctionpublic void setBindFunction(BiFunction<DatabaseClient.GenericExecuteSpec, ?, DatabaseClient.GenericExecuteSpec> bindFunction) Set aBiFunctionwhich is used to bind parameters into the update query.- Parameters:
- bindFunction- the- BiFunctionto use.
 
- 
setExpectSingleResultpublic void setExpectSingleResult(boolean expectSingleResult) The flag to manage which find* method to invoke onR2dbcEntityOperations. Default is 'false', which means theAbstractMessageSource.receive()method will use theDatabaseClient.sql(String)method and will fetch all. If set to 'true'AbstractMessageSource.receive()will useDatabaseClient.sql(String)and will fetch one and the payload of the returnedMessagewill be the returned target Object of type identified bypayloadTypeinstead of a List.- Parameters:
- expectSingleResult- true if a single result is expected.
 
- 
getComponentType
- 
onInitprotected void onInit()- Overrides:
- onInitin class- AbstractExpressionEvaluator
 
- 
doReceiveExecute a query returning its results as the Message payload. The payload can be eitherFluxorMonoof objects of type identified bypayloadType, or a single element of type identified bypayloadTypebased on the value ofexpectSingleResultattribute which defaults to 'false' resultingMessagewith payload of typeFlux.- Specified by:
- doReceivein class- AbstractMessageSource<org.reactivestreams.Publisher<?>>
- Returns:
- The value returned.
 
 
-