Q4Mを使ってみる。その2

チュートリアル続き

queue_wait()で、OWNERモードに入り、queue_end()でOWNERモードが解除し、ハンドルされていた値はキューから抜ける。という動きの確認を行った。
次は、queue_abort()。わざわざ確認する必要もない気もするが一様。

When clients fail in handling the row, it should call queue_abort function, that returns the owned-row to the table so that it could be handled by other clients.

と書いてある通り、ハンドルに失敗した場合、キューから値が抜けてしまうと困るのでqueue_end()ではなく、queue_abort()を呼ぶ。

 mysql> select * from my_queue where queue_wait('my_queue');
 +----+--------------+
 | v1 | v2           |
 +----+--------------+
 |  2 | hello world! |
 +----+--------------+
 1 row in set (0.00 sec)
 
 mysql> SELECT queue_abort();
 +---------------+
 | queue_abort() |
 +---------------+
 |             1 |
 +---------------+
 1 row in set (0.00 sec)
 
 mysql> select * from my_queue;
 +----+--------------+
 | v1 | v2           |
 +----+--------------+
 |  2 | hello world! |
 |  3 | hello world! |
 |  4 | hello world! |
 |  5 | hello world! |
 +----+--------------+
 4 rows in set (0.00 sec)

キューに格納されている値は元のまま消えない。