Abstract Routing Datasource

Hi,

I am trying to implement AbstractRoutingDataSource using @within with @RoutableDataSource to route database request to read or write database according to below

@Transactional(readOnly=false) or @Transactional
if (transactional.readOnly()) {
    DatabaseContextHolder.set(DatabaseEnvironment.READONLY);
} else {
    DatabaseContextHolder.set(DatabaseEnvironment.UPDATABLE); 
}

but concern is when is redirect datamanger or jdbctemplate request routable related class logs are getting printed and getting work as per if else condition but still it is redirected as per them source define to entity main or slave database. What i understood is datasource is already initialize even though if i add redirect logic. Even i create separate service class to mark routable annotation still it doesn’t work.