Reputation: 93
I created a Java program that every 30 Minutes, reads information from a database, keeping them in a structure Vector<Vector<Object>>
.
To do this use ScheduledExecutorService
.
I created a second Java program that allows you to Add/Modify/Delete items from the database. How do I inform the first program that some changes took place in the database and then re-read the new information without waiting the 30 minutes?
The first program is always active, while the second is executed only in the case where it is necessary to make a change.
Upvotes: 1
Views: 183
Reputation: 26946
If you can add/modify/delete items only from the second java program you can call a method of the first program.
The easiest way to do that is to expose a web service from the first program that can be called from the second every time the database has been modified.
But if you can modify the database items also directly on the database you need to create a trigger on the database and invoke the web service directly from the database. Note that this second approach (calling a ws directly on trigger events) is a bad practice. In this case you can combine both procedures: call directly a ws if a modifications happens from the second java program and leave the polling active for modifications done directly on the database.
Upvotes: 1