public class AmazonRdsReadReplicaAwareDataSourceFactoryBean extends AmazonRdsDataSourceFactoryBean
AmazonRdsDataSourceFactoryBean
sub-class that is
capable to handle amazon rds read-replicas. This is especially useful in case of
read-heavy applications to leverage read-replica instance for all read-accesses.logger
OBJECT_TYPE_ATTRIBUTE
Constructor and Description |
---|
AmazonRdsReadReplicaAwareDataSourceFactoryBean(com.amazonaws.services.rds.AmazonRDS amazonRDS,
String dbInstanceIdentifier,
String password)
Constructor which retrieves all mandatory objects to allow the object to be
constructed.
|
Modifier and Type | Method and Description |
---|---|
protected DataSource |
createInstance()
Constructs a
ReadOnlyRoutingDataSource
data source that contains the regular data source as a default, and all
read-replicas as additional data source. |
protected void |
destroyInstance(DataSource instance) |
createDataSourceInstance, getDbInstance, getDbInstanceIdentifier, getObjectType, setDatabaseName, setDataSourceFactory, setResourceIdResolver, setUsername
afterPropertiesSet, destroy, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton
public AmazonRdsReadReplicaAwareDataSourceFactoryBean(com.amazonaws.services.rds.AmazonRDS amazonRDS, String dbInstanceIdentifier, String password)
amazonRDS
- - The amazonRDS instance used to connect to the service. This
object will be used to actually retrieve the datasource metadata from the Amazon
RDS service.dbInstanceIdentifier
- - the unique database instance identifier in the Amazon
RDS servicepassword
- - The password used to connect to the datasource. For security
reasons the password is not available in theprotected DataSource createInstance() throws Exception
ReadOnlyRoutingDataSource
data source that contains the regular data source as a default, and all
read-replicas as additional data source. The
ReadOnlyRoutingDataSource
is additionally
wrapped with a
LazyConnectionDataSourceProxy
, because
the read-only flag is only available after the transactional context has been
established. This is only the case if the physical connection is requested after
the transaction start and not while starting a transaction.createInstance
in class AmazonRdsDataSourceFactoryBean
Exception
- if the underlying data source setup throws any exceptionprotected void destroyInstance(DataSource instance) throws Exception
destroyInstance
in class AmazonRdsDataSourceFactoryBean
Exception
Copyright © 2023 Pivotal Software, Inc.. All rights reserved.