0

I am working on a Spring Boot Batch application. I have problem with Batch Metadata tables in production. It gives deadlock on Metadata table update. I have two doubts

1) Is it possible to bye-pass Metadata table data insertion? but still need to insert data to my application database

2) If the above approach is not possible, is it possible to have metadata table entry only to a separate datasource?

User_1940878
  • 321
  • 1
  • 6
  • 25
  • 1) No. Spring Batch doesn't work without the batch tables 2) Yes. but this may not solve your problem. What database are you using and what's the exception you get? – Simon Martinelli Jun 07 '19 at 14:54
  • You could do this but you’d have to rewrite the project and use apache camel integration. There is an example of how here: https://github.com/abnair2016/spring-camel – Rob Scully Jun 07 '19 at 15:50
  • @user1940878 - Could you please share stack-trace error ? Deadlock error can be solved: https://stackoverflow.com/questions/26530205/multiple-spring-batch-jobs-executing-concurrently-causing-deadlocks-in-the-sprin. Please upvote, if this works – PAA Jun 08 '19 at 14:09
  • @PAA I am not using XML configurations. I have tried your approach in non xml way, but ends up in error. Kindly check this and suggest anything which i am missing https://stackoverflow.com/questions/56481045/batch-stuck-due-to-metadata-table-value-deletion – User_1940878 Jun 27 '19 at 14:20
  • @SimonMartinelli I am using Mysql db, the exception which i am getting is mentioned in the post -> https://stackoverflow.com/questions/56481045/batch-stuck-due-to-metadata-table-value-deletion – User_1940878 Jun 27 '19 at 14:23

1 Answers1

0

You should resolve Whatever the deadlock issue is. Any exception, StackTrace would help.

1) Yes. There is. BUT better use the metadata tables. If you insist, see below code. Doing this way spring batch will use the In Memory Map version for job repo.

public class BatchConfiguration extends DefaultBatchConfigurer {
    @Autowired(required = false)
    public void setDataSource(DataSource dataSource) {
       System.out.println("Not doing anything as we want no dataSource on the batch infrastructure stuff.");
       //super.setDataSource(null); //NOOP
    }

    // your other job and step bean configs.
}
Vivek
  • 5
  • 1
  • I have tried the above approach. Now the application not at all inserting data to any of the tables (Metadata as well as Business tables. It reads from tables correctly) – User_1940878 Jul 01 '19 at 07:51
  • Probably late but If you can post the configuration of batch job, that would be great. – Vivek Jul 16 '19 at 20:15