![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
hi guys, I'm developing a system in C++ with MYSQL. For a feature I need that the system have to be notified when in the database occur a specified event. In order to do this I thought at a couple of solution : 1) put one thread of the process in polling (every second, for example) to hear my event/s. 2) with trigger on mysql. When the event occur a trigger call a UDF (user defined function) that send it to my process. have you other (more elegant or simpler) solution ? many thanks. Ono. |
#3
| |||
| |||
|
|
What event do you want to be notified occurred |
#4
| |||
| |||
|
|
Il 17/11/2011 18:29, Jerry Stuckle ha scritto: What event do you want to be notified occurred Even only an event (from DB to process) "without" information that will notify about "In this table have occurred something" (the id is a plus ) ... thanks . |
#5
| |||
| |||
|
|
On 11/17/2011 12:50 PM, softwareEngineer wrote: Il 17/11/2011 18:29, Jerry Stuckle ha scritto: What event do you want to be notified occurred Even only an event (from DB to process) "without" information that will notify about "In this table have occurred something" (the id is a plus ) ... thanks . What do you mean "in this table have occurred something"? Someone inserted, modified or deleted a row? Someone retrieved data from a row? Someone ran OPTIMIZE TABLE? There are all kinds of things which can go on in a database. What exactly are you trying to accomplish? thanks Jerry, |
#6
| |||
| |||
|
|
Il 17/11/2011 19:56, Jerry Stuckle ha scritto: On 11/17/2011 12:50 PM, softwareEngineer wrote: Il 17/11/2011 18:29, Jerry Stuckle ha scritto: What event do you want to be notified occurred Even only an event (from DB to process) "without" information that will notify about "In this table have occurred something" (the id is a plus ) ... thanks . What do you mean "in this table have occurred something"? Someone inserted, modified or deleted a row? Someone retrieved data from a row? Someone ran OPTIMIZE TABLE? There are all kinds of things which can go on in a database. What exactly are you trying to accomplish? thanks Jerry, what I trying to explain is that when someone "update" a table mysql should, by trigger, to notify an external system (but on the same mysql machine) about the event. The logic does not change, do not focus about what on db occur ... focus on when the trigger occurs (and we are talking about solution 2) have to notify an external system .... bye. |
#7
| |||
| |||
|
|
The best way to handle problems like this IMHO would be not to have the UDF access the remote system directly, but to build a queue of outstanding requests. Then have another job (probably cron activated - although it could be running all the time) reads the queue and processes each request in it. |
#8
| |||
| |||
|
|
Il 18/11/2011 15:03, Jerry Stuckle ha scritto: The best way to handle problems like this IMHO would be not to have the UDF access the remote system directly, but to build a queue of outstanding requests. Then have another job (probably cron activated - although it could be running all the time) reads the queue and processes each request in it. the udf function (once called) blocks the server (mysql) ? Yes, I already thought at this. I thought at one thread that every second (?) verify if there is pending request in the db. great. bye. |
#9
| |||
| |||
|
|
On 11/18/2011 10:03 AM, softwareEngineer wrote: Il 18/11/2011 15:03, Jerry Stuckle ha scritto: The best way to handle problems like this IMHO would be not to have the UDF access the remote system directly, but to build a queue of outstanding requests. Then have another job (probably cron activated - although it could be running all the time) reads the queue and processes each request in it. the udf function (once called) blocks the server (mysql) ? Yes, I already thought at this. I thought at one thread that every second (?) verify if there is pending request in the db. great. bye. It depends on how rapidly you need the notifications, and how often the events happen. I would be very concerned about once per second, however. It could place a high load on the system, and there is a very good chance one thread may not complete before the new one starts. But again, the real question is what are you trying to accomplish? What you are requesting is highly unusual with any database. |
#10
| |||
| |||
|
|
Il 18/11/2011 16:09, Jerry Stuckle ha scritto: On 11/18/2011 10:03 AM, softwareEngineer wrote: Il 18/11/2011 15:03, Jerry Stuckle ha scritto: The best way to handle problems like this IMHO would be not to have the UDF access the remote system directly, but to build a queue of outstanding requests. Then have another job (probably cron activated - although it could be running all the time) reads the queue and processes each request in it. the udf function (once called) blocks the server (mysql) ? Yes, I already thought at this. I thought at one thread that every second (?) verify if there is pending request in the db. great. bye. It depends on how rapidly you need the notifications, and how often the events happen. I would be very concerned about once per second, however. It could place a high load on the system, and there is a very good chance one thread may not complete before the new one starts. But again, the real question is what are you trying to accomplish? What you are requesting is highly unusual with any database. from a web application one user send some data on db and this data will arrive at this application that are on the same machine of the db. that's all. |
![]() |
| Thread Tools | |
| Display Modes | |
| |