I created a Spring batch application using Spring boot, and I have a 9-step Job . These steps use the DataSource , which I created its bean in the configuration file as follows:
@Configuration public class DatabaseConfig { @ConfigurationProperties(prefix = "spring.datasource") @Bean @Primary public DataSource dataSource(){ return DataSourceBuilder.create().build(); } }
This DataSource uses the properties declared in the application.yml file:
spring: datasource: url: jdbc:mysql:
So far, everything is working as expected.
What I want to do is that I have 4 databases parameterized in the 5th database (db_settings), which I select using the SQL query. This query will return 4 databases with their usernames and passwords as follows:
+--------+-----------------------------------+-----------------+-----------------+ | id | url | username_db | password_db | +--------+-----------------------------------+-----------------+-----------------+ | 243 | jdbc:mysql://localhost:3306/db_01 | xxxx | **** | | 244 | jdbc:mysql://localhost:3306/db_02 | xxxx | **** | | 245 | jdbc:mysql://localhost:3306/db_03 | xxxx | **** | | 247 | jdbc:mysql://localhost:3306/db_04 | xxxx | **** | +--------+-----------------------------------+-----------------+-----------------+
So instead of running the steps using the database declared in 'application.yml', I want to run them in all four databases. And considering the volume being processed, it is necessary to be able to run batch processing of these databases in parallel.
Does anyone know how to implement this?
source share