Now that you're all using the wonders of Cooperative Consumers to help you efficiently and reliably implement your business constraints and offload them from the main user transactions, you're reaching a point where you have to clean up your development environment (because that's what happens to development environments, right?), and you want a way to start again from a clean empty place.

Here we go. It used to be much more simple than that, so if you're still using PGQ from Skytools2, just jump to the next step.
Unregister Subconsumers
That query will figure out subconsumers in the system function
pgq.get_consumer_info() and ask PGQ to please unregister them, losing events
in the way, even events from batches that are currently active.
with subconsumers as ( select q1.queue_name, q2.consumer_name, substring(q1.consumer_name from '%.#"%#"' for '#') as subconsumer_name from (select * from pgq.get_consumer_info() where lag is null) as q1 join (select * from pgq.get_consumer_info() where lag is not null) as q2 on q1.queue_name = q2.queue_name ) select *, pgq_coop.unregister_subconsumer(queue_name, consumer_name, subconsumer_name, 1) from subconsumers;
Unregister Consumers
Now that the first step is done, we have to unregister the main consumers, which is easy and what you already did before:
select queue_name, consumer_name, pgq.unregister_consumer(queue_name, consumer_name) from pgq.get_consumer_info();
Drop queues
And as we want to really clean up the mess, let's also drop the queues.
select queue_name, pgq.drop_queue(queue_name) from pgq.queue;
Tags
Previous Articles
- pgbouncer munin plugin Wednesday, November 16 2011, 14:00
- Battle Language à la Marmite Thursday, March 01 2012, 14:49
- Extension White Listing Thursday, March 08 2012, 14:25
- PGQ Coop Consumers Monday, March 12 2012, 14:43
Next Articles
- Back From PgCon Thursday, May 24 2012, 09:40
- M-x recompile Friday, June 01 2012, 18:45
- PGDay France 2012 Friday, June 08 2012, 16:17
- Solving Every Sudoku Puzzle Tuesday, July 10 2012, 20:37

