<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How to notify event listeners in MySQL</title>
	<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/</link>
	<description>Stay curious!</description>
	<pubDate>Wed, 09 Jul 2008 03:48:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: Ichae</title>
		<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13700</link>
		<author>Ichae</author>
		<pubDate>Thu, 22 Nov 2007 04:42:12 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13700</guid>
		<description>Is there a way to implement a connectionless lock in MySQL?  The locking mechanism would be perfect for me, except that I can't maintain a connection.  I want to issue a query to get the lock, then go away for a long period, and then come back and unlock it later.  As far as I can tell, a lock is the only method to get a MySQL query to block until something else tells it not to, so I'm not seeing any other way to implement it...</description>
		<content:encoded><![CDATA[<p>Is there a way to implement a connectionless lock in MySQL?  The locking mechanism would be perfect for me, except that I can&#8217;t maintain a connection.  I want to issue a query to get the lock, then go away for a long period, and then come back and unlock it later.  As far as I can tell, a lock is the only method to get a MySQL query to block until something else tells it not to, so I&#8217;m not seeing any other way to implement it&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13356</link>
		<author>Xaprb</author>
		<pubDate>Thu, 30 Aug 2007 20:46:35 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13356</guid>
		<description>Yeah, I forgot to point out that this is totally a DB-centric approach.  There are much better ways for a stateful app.</description>
		<content:encoded><![CDATA[<p>Yeah, I forgot to point out that this is totally a DB-centric approach.  There are much better ways for a stateful app.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay Pipes</title>
		<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13355</link>
		<author>Jay Pipes</author>
		<pubDate>Thu, 30 Aug 2007 20:40:30 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13355</guid>
		<description>Hi Baron!  Cool article.  Should be noted, though, that this is only relevant for stateless, request-response oriented applications.  Using an Observer/Observable pattern in stateful applications would be a better option for those platforms that support state.  The Observers register with an Observable object and once a condition/event occurs, all observers are notified...

Cheers!

Jay</description>
		<content:encoded><![CDATA[<p>Hi Baron!  Cool article.  Should be noted, though, that this is only relevant for stateless, request-response oriented applications.  Using an Observer/Observable pattern in stateful applications would be a better option for those platforms that support state.  The Observers register with an Observable object and once a condition/event occurs, all observers are notified&#8230;</p>
<p>Cheers!</p>
<p>Jay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rdb Notes &#183; How to notify event listeners in MySQL at Xaprb</title>
		<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13354</link>
		<author>Rdb Notes &#183; How to notify event listeners in MySQL at Xaprb</author>
		<pubDate>Thu, 30 Aug 2007 15:05:38 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13354</guid>
		<description>[...]  How to notify event listeners in MySQL at Xaprb  A high-performance application that has producers and consumers of some resource, such as a queue of messages, needs an efficient way to notify the consumers when the producer has inserted into the queue. Polling the queue for changes is not a good option. MySQL’s GET_LOCK() and RELEASE_LOCK() functions can provide both mutual exclusivity and notifications. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;]  How to notify event listeners in MySQL at Xaprb  A high-performance application that has producers and consumers of some resource, such as a queue of messages, needs an efficient way to notify the consumers when the producer has inserted into the queue. Polling the queue for changes is not a good option. MySQL’s GET_LOCK() and RELEASE_LOCK() functions can provide both mutual exclusivity and notifications. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13352</link>
		<author>Xaprb</author>
		<pubDate>Thu, 30 Aug 2007 14:04:02 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13352</guid>
		<description>What are the pitfalls with advisory locking functions?</description>
		<content:encoded><![CDATA[<p>What are the pitfalls with advisory locking functions?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arjen Lentz</title>
		<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13351</link>
		<author>Arjen Lentz</author>
		<pubDate>Thu, 30 Aug 2007 14:01:36 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-13351</guid>
		<description>I've tended to advise against using MySQL's advisory locking functions, there are enough pitfalls to make it undesirable in terms of relying on it for an application.

There are other cheap ways to make it work.
Various people have written UDFs that write to UDP sockets. That's useful.

But a really simple method would be to put a trigger on the table, and have a secondary table (MyISAM) with just one row. The trigger would just insert ignore on a row with a fixed ID and a primary/unique key. A reader deletes the row. The queue can then be checked with a SELECT COUNT(*) FROM onerowtbl, which with MyISAM is a very fast operation. It you don't like triggers, the secondary table can be manually updated by the writer application. Same result.

I just made up the above as I was writing the reply... there might be other and better solutions. The point is, the above would be reliable.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve tended to advise against using MySQL&#8217;s advisory locking functions, there are enough pitfalls to make it undesirable in terms of relying on it for an application.</p>
<p>There are other cheap ways to make it work.<br />
Various people have written UDFs that write to UDP sockets. That&#8217;s useful.</p>
<p>But a really simple method would be to put a trigger on the table, and have a secondary table (MyISAM) with just one row. The trigger would just insert ignore on a row with a fixed ID and a primary/unique key. A reader deletes the row. The queue can then be checked with a SELECT COUNT(*) FROM onerowtbl, which with MyISAM is a very fast operation. It you don&#8217;t like triggers, the secondary table can be manually updated by the writer application. Same result.</p>
<p>I just made up the above as I was writing the reply&#8230; there might be other and better solutions. The point is, the above would be reliable.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
