How to use the kombu.Connection function in kombu

To help you get started, we’ve selected a few kombu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RackHD / RackHD / test / stream-monitor / stream_sources / amqp_od / rackhd_amqp_od.py View on Github external
def __setup_rackhd_style_amqp(self):
        """
        Need to make exchanges and named queus to make this
        look like a RackHD instance amqp.
        """
        con = Connection(hostname=self.host, port=self.ssl_port, ssl=False)
        on_task = self.__assure_exchange(con, 'on.task', 'topic')
        self.__assure_named_queue(con, on_task, 'ipmi.command.sel.result')
        self.__assure_named_queue(con, on_task, 'ipmi.command.sdr.result')
        self.__assure_named_queue(con, on_task, 'ipmi.command.chassis.result')

        on_events = self.__assure_exchange(con, 'on.events', 'topic')
        self.__assure_named_queue(con, on_events, 'graph.finished')
        self.__assure_named_queue(con, on_events, 'polleralert.sel.updated', '#')

        self.__assure_exchange(con, 'on.heartbeat', 'topic')
github mozilla / version-control-tools / testing / vcttesting / util.py View on Github external
def wait_for_amqp(hostname, port, userid, password, ssl=False, timeout=60,
                  extra_check_fn=None):
    # Delay import to facilitate module use in limited virtualenvs.
    import kombu
    c = kombu.Connection(hostname=hostname, port=port, userid=userid,
            password=password, ssl=ssl)

    start = time.time()

    while True:
        try:
            c.connection
            return
        except Exception:
            pass

        if extra_check_fn:
            extra_check_fn()

        if time.time() - start > timeout:
            raise Exception('Timeout reached waiting for AMQP')
github celery / kombu / t / unit / transport / test_pyamqp.py View on Github external
def setup(self):
        self.connection = Connection('pyamqp://')
        self.transport = self.connection.transport
github wazo-platform / wazo-calld / wazo_calld / bus.py View on Github external
def run(self):
        logger.info("Running AMQP consumer")
        with Connection(self._bus_url) as connection:
            self.connection = connection

            super().run()
github LiuRoy / github_spider / github_spider / queue / producer.py View on Github external
def __init__(self, exchange_name, broker_url, mode=ASYNC):
        """初始化生产者

        Args:
            exchange_name (string): 路由名称
            broker_url (string): 连接地址
            mode (int): 发送
        """
        self.exchange_name = exchange_name
        self.broker_url = broker_url
        self.mode = mode

        self.exchange = Exchange(exchange_name, type='direct')
        self.connection = Connection(broker_url)
github projectatomic / commissaire / features / environment.py View on Github external
start_commissaire_service, 'commissaire-watcher-service',
                context, [
                    'commissaire-watcher-service',
                    '--config-file',
                    '../commissaire-service/conf/watcher.conf'])

        if context.config.userdata.get('start-commissaire-server'):
            context.PROCESSES['commissaire-server'] = try_start(
                start_commissaire_server, 'commissaire-server',
                context, [
                    '--authentication-plugin',
                    'commissaire_http.authentication.httpbasicauth:'
                    'filepath=../commissaire-http/conf/users.json'])

    # Set up a Kombu queue to receive notifications.
    context.BUS_CONNECTION = kombu.Connection(context.BUS_URI)
    channel = context.BUS_CONNECTION.default_channel
    exchange = kombu.Exchange(
        name='commissaire',
        type='topic',
        channel=channel)
    context.NOTIFY_QUEUE = kombu.Queue(
        name='behave-tests',
        exchange=exchange,
        routing_key='notify.storage.*.*',
        channel=channel)
    context.NOTIFY_QUEUE.declare()
github getlogbook / logbook / logbook / queues.py View on Github external
def __init__(self, uri=None, queue='logging', level=NOTSET,
                 filter=None, bubble=False):
        Handler.__init__(self, level, filter, bubble)
        try:
            import kombu
        except ImportError:
            raise RuntimeError('The kombu library is required for '
                               'the RabbitMQSubscriber.')
        if uri:
            connection = kombu.Connection(uri)

        self.queue = connection.SimpleQueue(queue)
github klahnakoski / SpotManager / vendor / pyLibrary / env / pulse.py View on Github external
def connect(self):
        if not self.connection:
            self.connection = Connection(
                hostname=self.settings.host,
                port=self.settings.port,
                userid=self.settings.user,
                password=self.settings.password,
                virtual_host=self.settings.vhost,
                ssl=self.settings.ssl
            )
github mozilla / MozDef / mq / esKworker.py View on Github external
def main():
    #connect and declare the queues
    connString='amqp://guest:guest@{0}:5672//'.format(options.mqserver)
    mqConn=Connection(connString)
    eventTaskQueue=Queue(options.taskqueue)
    eventTaskQueue(mqConn).declare()
    kConsumer(mqConn,eventTaskQueue,es).run()
github pangyemeng / myjob / pyspider / pyspider_es / pyspider / message_queue / kombu_queue.py View on Github external
def __init__(self, name, url="amqp://", maxsize=0, lazy_limit=True):
        """
        Constructor for KombuQueue

        url:        http://kombu.readthedocs.org/en/latest/userguide/connections.html#urls
        maxsize:    an integer that sets the upperbound limit on the number of
                    items that can be placed in the queue.
        """
        self.name = name
        self.conn = Connection(url)
        self.queue = self.conn.SimpleQueue(self.name, no_ack=True, serializer='umsgpack')

        self.maxsize = maxsize
        self.lazy_limit = lazy_limit
        if self.lazy_limit and self.maxsize:
            self.qsize_diff_limit = int(self.maxsize * 0.1)
        else:
            self.qsize_diff_limit = 0
        self.qsize_diff = 0