K
K
Konstantin Malyarov2016-01-04 10:10:14
MySQL
Konstantin Malyarov, 2016-01-04 10:10:14

DB update notifications, how to implement?

There is a DB, wrote on java the program which pulls out the list from the table. When you click on the "update" button, the list is updated (the table is re-queried, rows are deleted, added, updated), the updated table is displayed.
How to make push notifications? About appearance, updating, removal of a line in the table?
Option to poll by timing - already implemented. We need other options. If possible with an example.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
P
protven, 2016-01-04
@protven

Well, as an option, use triggers in the database, which, after triggering, initiate a request from the database to your program via some interface. But this is, IMHO, bad practice. I don't know how it is in mysql, but once I had to maintain an "enterprise solution", in which most of the business logic and even part of the transport layer of the application was thrust into the database (Oracle). Well, that is, the butt pulled the storage in the database, the storage pulled the external system via http (!) And then the received response was also transmitted via http back to the application (!!). Support and trouble-joke it was all PPC how difficult.

P
Pavel Dudenkov, 2016-01-04
@viperz

I don't know if this is a good practice. It's just that I immediately came up with a "cheap" implementation option.
Oracle has SCN , something like the internal clock of this DBMS, each change in the database will be marked by an increment of this "time".
By the same principle, you can track changes, i.e. make a counter (for example, in one table one row with one column that stores an entire variable) of database changes. Well, accordingly, in your program, you remember the last value, and then make a banal selection of this counter from the database.

A
angry_cellophane, 2016-01-08
@angry_cellophane

Set up a messaging server. The server will water the database (and it is even better to carry out all operations with the database through it - then there is no need to water it), create messages (create, delete, update lines in the tables). Messages are stored and transmitted to the client by some messaging system, for example, by some JMS broker.
Messaging systems were invented for such tasks.

A
Anton Chernousov, 2016-01-04
@tech22

Hmm... We hang a bunch of change triggers that will change one value in the 0/1 table further on the crowns we hang an alarmist who polls the status with a script. With Postgres, you can query the log for what has changed there.

C
coderisimo, 2016-01-04
@coderisimo

https://www.pubnub.com/knowledge-base/discussion/2...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question