Spring Boot multiple datasources on same database

Viewed 105

I was reviewing a code which seems to lose connection to DB approximately once a month intermittently. It leaves no logs on DB side but server prints a log of Connection closed by peer.

  • Its a Spring Boot App (2.1.9) which uses Spring Integration to read from queues (JMS).
  • Under pom.xml spring-boot-started-jdbc , Hikari is excluded and tomcat is used.
  • The app is designed in such a way that it has an in-queue to get traffic, then series of internal queues to split the workload and finally an out queue to the destination.
  • This app has 4 datasources created all pointing to the same oracle database.
  • First datasource is used for all CRUD operations in the flow between in-queue and first internal queue. Second datasource is used for all CRUD operations in the flow between first and second internal queue. Third datasource is used between second internal queue and destination queue. Fourth datasource is not used anywhere which suggests some flow was commented but datasource was never removed.
  • Each datasource has different min and max connections but rest of the properties are same.
  1. Wanted to understand is that a good practice to create datasources for each spring integration flow pointing to same database?
  2. Can it cause any problems to leave a datasource initialized without using it anywhere?
  3. Is there any obvious reason why HikariCP shouldn't be chosen for production when lot of matrix online show Hikari is superior to Tomcat and Spring boot 2 has chosen it as default for a reason?
0 Answers
Related