[英]spring batch with multiple datasources at runtime
I have to crawl across some configured databases in a table . 我必须在表中搜寻一些已配置的数据库。 where each record specifies a schema to be read from .
每个记录都指定要从中读取的模式。 So we have to poll the table and run the job appropriately.
因此,我们必须轮询表并适当地运行作业。
thought to use Spring batch(JdbcPagingItemReader) to read data from all the Schema's configured. 被认为使用Spring批处理(JdbcPagingItemReader)从所有已配置的Schema中读取数据。 if i have to configure this, How can i do it using Spring Batch ?
如果我必须配置它,如何使用Spring Batch做到这一点?
should i take multiple jobs with different reader for each database to read from, or is there any way where i can send the datasource at runtime for the Spring Batch to read data from ? 我应该使用不同的读取器来为每个数据库读取多个作业,还是应该以某种方式在运行时发送数据源以供Spring Batch读取数据?
How can i manage Multiple databases for Single Spring Batch. 如何为单个Spring Batch管理多个数据库。 If not is there any other suggestion for the Database Crawling(or Harvesting)?
如果没有,那么是否有其他有关数据库爬网(或收获)的建议?
If you are just running a query to get some data to then run other queries then this is not really something that aligns with what Spring Batch does. 如果您只是在运行查询以获取一些数据然后再运行其他查询,那么这实际上与Spring Batch的功能不符。 That just a standard JDBC or JPA type DAO/Service setup.
那只是一个标准的JDBC或JPA类型的DAO / Service设置。 You can use Quartz or Spring Scheduler to set a CRON value for when you what it to check the table(s).
您可以使用Quartz或Spring Scheduler为检查表的时间设置CRON值。
There are 2 solutions using Spring Batch : 使用Spring Batch有2个解决方案:
DataSource
properties (url, username, password....) at runtime through JobParameters
. JobParameters
传递DataSource
属性(URL,用户名,密码...)。 This means that the reading logic of the first read (the one which tells you what to read) has to be done outside the job JobExecutionContext
and the second one doing the actual read using previously stored values at runtime JobExecutionContext
执行“元数据”读取并将结果存储在JobExecutionContext
,第二个步骤在运行时使用先前存储的值进行实际读取
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.