Just setup my first spring-boot-batch project using spring-data-jpa. I have a working solution in my dev environment, whereby I consume some rows from an Oracle DB in my itemReader, parse some xml/html out in my processor for each row, then write out each extracted html out to an individual file using a custom itemWriter. (1 file per row)
My datasource is configured via spring-data-jpa in the boot project (application.properties)...
I noticed OOTB spring-batch creates various schema objects for its jobRepository using the available datasource.
This is fine in a dev environment, but i only have "read" access in our production Oracle DB environment where my itemReader will be gettings its official data.
I tried configuring 2 datasources as outlined in the spring docs i came across.. but couldn't get it working. I also tried using in-memory instead, but couldn't get that working either.
So is this possible? Or should I keep plugging away at getting the in-memory job repo working?
I'm not too concerned with restartability at this point.. batch job will be run on my desktop as a standalone spring-boot application.
Any help, tips, information is greatly appreciated.
Update:
Trying the in-memory configuration, here is part of my batch config class:
@Configuration
@EnableBatchProcessing
public class BatchConfiguration {
private static final Logger log = LoggerFactory.getLogger(BatchConfiguration.class);
@Autowired
public JobBuilderFactory jobBuilderFactory;
@Autowired
public StepBuilderFactory stepBuilderFactory;
@Autowired
EntityManagerFactory emf;
@Bean
public SimpleJobLauncher jobLauncher(JobRepository jobRepository) {
SimpleJobLauncher simpleJobLauncher = new SimpleJobLauncher();
simpleJobLauncher.setJobRepository(jobRepository);
return simpleJobLauncher;
}
@Bean
public JobRepository jobRepository(ResourcelessTransactionManager transactionManager) throws Exception {
MapJobRepositoryFactoryBean mapJobRepositoryFactoryBean = new MapJobRepositoryFactoryBean(transactionManager);
mapJobRepositoryFactoryBean.setTransactionManager(transactionManager);
return mapJobRepositoryFactoryBean.getObject();
}
@Bean
public ResourcelessTransactionManager transactionManager() {
return new ResourcelessTransactionManager();
}
Project compiles ok, but when i run, i get the following:
Caused by: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? order by JOB_INSTANCE_ID desc]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
So seems its still trying to hook up to Oracle, and not use the in-memory DB..