Exemple #1
0
class QueueUnbindHandler(Handler):
    group = 'queue'
    name = 'unbind'

    meta_arguments = (
        StringArgument('queue', 'queue name'),
        StringArgument('exchange', 'The name of the exchange to bind to'),
        StringArgument('routing_key', 'message routing key'),
    )

    def run(self):
        self.channel.queue_unbind(**self.parsed_arguments)
Exemple #2
0
class ExchangeDeclareHandler(Handler):
    group = 'exchange'
    name = 'declare'

    meta_arguments = (
        StringArgument('exchange', 'the name of the exchange'),
        StringArgument('type', 'exchange type'),
        BoolArgument('passive', 'do not create exchange'),
        BoolArgument('durable', 'request a durable exchange'),
        BoolArgument('auto_delete', 'auto-delete when unused'),
    )

    def run(self):
        self.channel.exchange_declare(**self.parsed_arguments)
Exemple #3
0
class BasicPublishHandler(Handler):
    group = 'basic'
    name = 'publish'

    meta_arguments = (
        MessageArgument('msg', 'message'),
        StringArgument('exchange',
                       'Specifies the name of the exchange to publish to'),
        StringArgument('routing_key', 'Message routing key'),
        BoolArgument('mandatory', 'indicate mandatory routing'),
        BoolArgument('immediate', 'request immediate delivery'),
    )

    def run(self):
        self.channel.basic_publish(**self.parsed_arguments)
Exemple #4
0
class QueuePurgeHandler(Handler):
    group = 'queue'
    name = 'purge'

    meta_arguments = (StringArgument('queue', 'queue name'), )

    def run(self):
        self.channel.queue_purge(**self.parsed_arguments)
Exemple #5
0
class ExchangeDeleteHandler(Handler):
    group = 'exchange'
    name = 'delete'

    meta_arguments = (
        StringArgument('exchange', 'the name of the exchange'),
        BoolArgument('if_unused', 'delete only if unused'),
    )

    def run(self):
        self.channel.exchange_delete(**self.parsed_arguments)
Exemple #6
0
class QueueDeleteHandler(Handler):
    group = 'queue'
    name = 'delete'

    meta_arguments = (
        StringArgument('queue', 'queue name'),
        BoolArgument('if_unused', 'delete only if unused'),
        BoolArgument('if_empty', 'delete only if empty'),
    )

    def run(self):
        msg_count = self.channel.queue_delete(**self.parsed_arguments)
        UserInterface.output("{} messages deleted".format(msg_count))
Exemple #7
0
class BasicGetHandler(Handler):
    group = 'basic'
    name = 'get'

    meta_arguments = (
        StringArgument('queue', 'the name of the queue to directly access to'),
        BoolArgument('no_ack', 'no acknowledgment needed'),
    )

    def run(self):
        reply = self.channel.basic_get(**self.parsed_arguments)
        if reply:
            UserInterface.output(reply.body)
            UserInterface.output(reply.delivery_info)
        else:
            UserInterface.output("no msg.")
Exemple #8
0
class QueueDeclareHandler(Handler):
    group = "queue"
    name = "declare"

    meta_arguments = (
        StringArgument("queue", "queue name"),
        BoolArgument("passive", "is passive queue", default=True),
        BoolArgument("durable", "is durable queue"),
        BoolArgument("exclusive", "is exclusive queue"),
        BoolArgument("auto_delete",
                     "the queue could be automatically deleted"),
    )

    def run(self):
        queue, msg_count, consumer_count = self.channel.queue_declare(
            **self.parsed_arguments)
        UserInterface.output(
            "Queue: {}, msg_count: {}, consumer_count: {}".format(
                queue, msg_count, consumer_count))