Ejemplo n.º 1
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a queue")

        queue = args[0]
        interactive = options['interactive']
        requeue = options['requeue']

        client = AMQPClient()
        client.connect()

        pp = pprint.PrettyPrinter(indent=4, width=4)

        more_msgs = True
        counter = 0
        sep = '-' * 80
        while more_msgs:
            msg = client.basic_get(queue=queue)
            if msg:
                counter += 1
                print sep
                print 'Message %d:' % counter
                print sep
                pp.pprint(msg)
                if not requeue or interactive:
                    if interactive and not get_user_confirmation():
                        continue
                    # Acknowledging the message will remove it from the queue
                    client.basic_ack(msg)
            else:
                more_msgs = False
Ejemplo n.º 2
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a queue")

        queue = args[0]
        interactive = options['interactive']
        requeue = options['requeue']

        client = AMQPClient()
        client.connect()

        pp = pprint.PrettyPrinter(indent=4, width=4, stream=self.stdout)

        more_msgs = True
        counter = 0
        sep = '-' * 80
        while more_msgs:
            msg = client.basic_get(queue=queue)
            if msg:
                counter += 1
                self.stderr.write(sep + "\n")
                self.stderr.write('Message %d:\n' % counter)
                self.stderr.write(sep + "\n")
                pp.pprint(msg)
                if not requeue or interactive:
                    if interactive and not get_user_confirmation():
                        continue
                    # Acknowledging the message will remove it from the queue
                    client.basic_ack(msg)
            else:
                more_msgs = False
Ejemplo n.º 3
0
    def handle(self, *args, **options):
        verbose = (options["verbosity"] == "2")
        self.keep_zombies = options["keep_zombies"]
        log_level = logging.DEBUG if verbose else logging.WARNING
        log.setLevel(log_level)

        client = AMQPClient(confirms=False)
        client.connect()

        self.client = client

        for queue in queues.QUEUES:
            dead_queue = queues.convert_queue_to_dead(queue)
            while 1:
                message = client.basic_get(dead_queue)
                if not message:
                    break
                log.debug("Received message %s", message)
                self.handle_message(message)
        client.close()
        return 0