Think Smart
Think Smart

Reputation: 41

How to know if database is updated or not using java program

I have two modules. For those two modules database is the common point

But here there is no connection between Module 1 & Module 2. Now my question is how the second module will trigger automatically when database values are updated? Is there any method to know database is updated or not?

Upvotes: 2

Views: 963

Answers (1)

Victor
Victor

Reputation: 8480

You have tree options:

  1. Create a procedure in database listening when there is new updates
  2. Store in your Module A a flag with the last updated field and check every t seconds if has any updated row
  3. Create a messaging interface between the two services.

My comments:

  1. Avoid that solution. It is a BAD SOLUTION! It is difficult to track with the code.
  2. It can be a good solution if you know that your system will not grow.
  3. If you see in the future more modules that can communicate with each other. Do that! Choose a good Message Queue (RabbitMQ, ActiveMC, etc...) or use you cloud solution (AWS has SQS)

Communication between two independent modules using database is not a good solution. Because if you change the database schema you will need to make two deploys. If you only need the data, you can use a Message solution using Protobuf as serializer.

Upvotes: 1

Related Questions