Delete rabbitmq queues which start with particular name

12/2/2021

I am trying to delete rabbitmq queues in a particular vhost using kubectl command. If I give below command I am able to delete the queue.

kubectl.exe exec -n kayaks svc/rabbitmq-ha -- rabbitmqctl --vhost=AM-Dev delete_queue 'TestDeletion'

But I want to delete a set of queues which all begin with some particular name like 'woms-'. How to accomplish the same. I tried below but it throws syntax error and I am unable to identify problem.

kubectl exec -n kayaks svc/rabbitmq-ha -- rabbitmqctl --vhost=AM-Dev eval 'IfUnused = false, IfEmpty = true,
MatchRegex = <<"^woms-">>, [rabbit_amqqueue:delete(Q, IfUnused, IfEmpty) || Q <- 
rabbit_amqqueue:list(), re:run(element(4, element(2, Q)), MatchRegex) 
=/= nomatch ].' 
****kubectl : Error (argument validation): "syntax error before: '^'"
At line:1 char:1
+ kubectl exec -n kayaks svc/rabbitmq-ha -- rabbitmqctl --vhost=AM-Dev  ...****

Can someone guide me as to what is the mistake I am doing.

-- ckv
kubernetes
rabbitmq
rabbitmqctl

0 Answers