How to synchronize the Hibernate second-level cache with the database across multiple JVMs

#1

I have a stand alone java batch process which does load the database tables from third party soap service. We have now a requirement to create a new rest services to read the database.

We have created a caching for my second rest component. It works fine. However, the question is the standalone batch component updates the database every 10 minutes and how do we ensure that the cache in my rest service component is synchronized and up-to date.

0 Likes

#2

I have a standalone Java batch process which does load the database tables from third-party soap service.

What database does it load? What does the Jaba batch process do with the data that it loads afterwards?

We have now a requirement to create a new rest services to read the database.

What database are you talking about?

We have created a caching for my second rest component.

Why did you create a cache? Are you using Hibernate? Maybe a second-level cache would work too?

However, the question is the standalone batch component updates the database every 10 minutes and how do we ensure that the cache in my rest service component is synchronized and up-to date.

Again, are you using Hibernate?

0 Likes

#3
  1. Both the standalone batch process and rest service use Oracle database and Hibernate.
  2. The standalone batch process query the soap service and if any updates, it only persists into the database.
  3. Yes, I did configure the secondary level cache in both the components. However, these components are residing in different servers.
0 Likes

#4

Then you can use Debezium to extract the CDC (Change Data Capture) events and update the cache accordingly.

Check out this article on the Debezium blog for more details about using this approach.

0 Likes