On 13/02/15 15:40, Ivan Yurchenko wrote:
> AMQP have an option if-empty for queue's delete. So it's possible to do
> what I want from a piece of code run by cron. But is there a way to do
> this without writing code, via Rabbit's REST API, rabbitmqadmin etc?
There is no way to do this in the HTTP API as yet, although we do have a
bug open for it.
You can (as always!) use rabbitmqctl eval though:
$ rabbitmqctl eval 'IfUnused = false, IfEmpty = true, MatchRegex =
<<"^prefix-">>, [rabbit_amqqueue:delete(Q, IfUnused, IfEmpty) || Q <-
rabbit_amqqueue:list(), re:run(element(4, element(2, Q)), MatchRegex)
=/= nomatch ].'
The above will delete all empty queues in all vhosts that have a name
beginning with "prefix-". You can edit the variables IfUnused, IfEmpty,
and MatchRegex to taste.
Cheers, Simon