-1

I have a very basic communication software that uses database to save messages entered by PC1 and PC2 uses the same database to read these messages and vice versa. My problem is, I need a technique so that I can keep checking the database for new messages. Or I need something that invokes a method to download the message when new record is inserted in the database. At the moment I use a timer which checks the DB every minute regardless of a new record being inserted. I'm looking for a more efficient way to perform the same task.

Any suggestion is welcome.

Thank you

Noneedname
  • 47
  • 1
  • 7
  • Well logically speaking, checking every minute is pretty inefficient. I would have the database fire off oa notification upon recieving a message – DreadHeadedDeveloper Oct 06 '14 at 16:12
  • Exactly, I know it's inefficient. I thought about triggers or stored procedures too. But want to get some suggestions first. – Noneedname Oct 06 '14 at 16:13
  • this is also off-topic "too broad" and "opinion based" –  Oct 06 '14 at 16:35

1 Answers1

0

You can try Observer design pattern extending Java Observer. This design pattern when you get new message then notified.

I think this page very helpful for you. When should we use Observer and Observable

Community
  • 1
  • 1
Damith Ganegoda
  • 4,100
  • 6
  • 37
  • 46