dbTalk Databases Forums  

[OT] ? == mysql notification.

comp.databases.mysql comp.databases.mysql


Discuss [OT] ? == mysql notification. in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
softwareEngineer
 
Posts: n/a

Default [OT] ? == mysql notification. - 11-17-2011 , 10:32 AM






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.

Reply With Quote
  #2  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: [OT] ? == mysql notification. - 11-17-2011 , 11:29 AM






On 11/17/2011 11:32 AM, softwareEngineer wrote:
Quote:
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.


Not really enough information. What event do you want to be notified
occurred? That will determine what options are available to you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #3  
Old   
softwareEngineer
 
Posts: n/a

Default Re: [OT] ? == mysql notification. - 11-17-2011 , 11:50 AM



Il 17/11/2011 18:29, Jerry Stuckle ha scritto:
Quote:
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 .

Reply With Quote
  #4  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: [OT] ? == mysql notification. - 11-17-2011 , 12:56 PM



On 11/17/2011 12:50 PM, softwareEngineer wrote:
Quote:
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?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #5  
Old   
softwareEngineer
 
Posts: n/a

Default Re: [OT] ? == mysql notification. - 11-18-2011 , 03:55 AM



Il 17/11/2011 19:56, Jerry Stuckle ha scritto:
Quote:
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.

Reply With Quote
  #6  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: [OT] ? == mysql notification. - 11-18-2011 , 08:03 AM



On 11/18/2011 4:55 AM, softwareEngineer wrote:
Quote:
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.

Ah, now we know you want to notify an external system when someone
updates a table. That is critical information - until we understand
what conditions you want to notify that system, there is no way to
provide a meaningful answer to your question. For instance, a failed (or
successful) login to the database would require entirely different
processing than an INSERT to a table.

OK, so you want to do it when a table is updated. You can easily do
this with a UPDATE trigger and a UDF. That would be the easiest way.

The problem you're going to run into is what happens when the remote
system is not available immediately. You don't want to hang the entire
request waiting for a system which may not be back for hours. Also, a
lot of UPDATE requests in a short period of time can slow things down
due to normal delays in accessing remote systems.

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.

Hope these ideas help.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #7  
Old   
softwareEngineer
 
Posts: n/a

Default Re: [OT] ? == mysql notification. - 11-18-2011 , 09:03 AM



Il 18/11/2011 15:03, Jerry Stuckle ha scritto:
Quote:
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.

Reply With Quote
  #8  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: [OT] ? == mysql notification. - 11-18-2011 , 09:09 AM



On 11/18/2011 10:03 AM, softwareEngineer wrote:
Quote:
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.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #9  
Old   
softwareEngineer
 
Posts: n/a

Default Re: [OT] ? == mysql notification. - 11-18-2011 , 09:21 AM



Il 18/11/2011 16:09, Jerry Stuckle ha scritto:
Quote:
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.

Reply With Quote
  #10  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: [OT] ? == mysql notification. - 11-18-2011 , 12:25 PM



On 11/18/2011 10:21 AM, softwareEngineer wrote:
Quote:
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.


First thing would be - why doesn't the application get its data from the
database directly. The data will always be correct and there is less
chance of errors. That would be the way most applications work.

Or, if updates are going to always be from this web application, why not
have it send the data to the other application also (not as good though).

I think this could be done much easier than making the database jump
through hoops.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.