2

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

  • Module 1: Collects the information and store in database
  • Module 2: using database results perform the further action

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?

6
  • include a flag when inserting data. after processing that data, you alter the flag so you know that that entry has been processed Commented Mar 29, 2018 at 11:34
  • Why are you designing it in this way? Why can't you create a connection between Module 1 and Module 2 to say that data is available? Commented Mar 29, 2018 at 11:34
  • @JoeC Module1 will further run in different machines and collect the data and store data in database server. so Module2 will invoke when the database is updated Commented Mar 29, 2018 at 11:37
  • Make this an event based system and broadcast the update using observer/observable pattern. Commented Mar 29, 2018 at 11:38
  • @ XtremeBaumer how to include a flag Commented Mar 29, 2018 at 11:39

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.