In many database-dependent applications, you may want to make changes in a staging database and then switch over your live application so that the staging database becomes the live database. Dynamo’s switching facility is based on a class named atg.service.jdbc.SwitchingDataSource
. You can use a SwitchingDataSource
in place of a regular data source (such as an atg.service.jdbc.MonitoredDataSource
). The SwitchingDataSource
can be switched between two or more underlying DataSources
. All DataSource
method calls are passed through to the DataSource
specified by the currentDataSource
property of the SwitchingDataSource
. Note that each DataSource
that the SwitchingDataSource
points to must be of class atg.nucleus.JNDIReference
, with a JNDIName
property that points to an application server data source. See Configuring the Data Sources and Transaction Manager for more information.
The switching database is meant to complement the DBCopiers
. For example, if you are using ATG Commerce, you would copy the database using the database vendor’s native bulk copy tools, then switch your live site between your staging database.
Note: Unlike DBCopier
, Dynamo’s switching facility is a JDBC mechanism.
To set up and use a database switching service:
Configure
DataSources
that connect to your live and staging databases.Configure a
SwitchingDataSource
component, as described in Configuring a SwitchingDataSource.Configure the Repository components that use the
DataSources
to point to theSwitchingDataSource
. Also set the Repository components’cacheSwitchHot
property, as described in Database Switching and Repository Caches.Invoke the
prepareNextDataSource
andperformSwitch
methods of theSwitchingDataSource
, as described in Database Switching Methods.
Important: If you have multiple independent Dynamo clusters that share a single SDSRepository
, make sure each cluster uses a unique set of SwitchingDataSource
names. Otherwise, the clusters will interfere with each other during the switching process.