Files
zulip/zerver/management/commands/purge_queue.py
Zev Benjamin 233290d578 Add a management command to purge a rabbitmq queue
This is useful in debugging when you just want to discard all the
messages in a queue because they have the wrong structure.

(imported from commit 8559ac74f11841430b4d0c801d5506ebcb74c3eb)
2013-09-23 11:25:58 -04:00

18 lines
544 B
Python

from __future__ import absolute_import
from django.core.management.base import BaseCommand
from django.core.management import CommandError
from zerver.lib.queue import SimpleQueueClient
import logging
class Command(BaseCommand):
args = "<queue name>"
help = "Discards all messages from the given queue"
def handle(self, *args, **options):
if len(args) != 1:
raise CommandError("Wrong number of arguments")
queue_name = args[0]
queue = SimpleQueueClient()
queue.drain_queue(queue_name)