Ejemplo n.º 1
0
 def listen(self, target, batch_size, batch_timeout):
     """Construct a Listener for the given target."""
     LOG.debug("Listen to %s", target)
     listener = ProtonListener(self)
     self._ctrl.add_task(drivertasks.ListenTask(target, listener))
     return base.PollStyleListenerAdapter(listener, batch_size,
                                          batch_timeout)
     return listener
Ejemplo n.º 2
0
 def listen(self, target, batch_size, batch_timeout):
     listener = pika_drv_poller.RpcServicePikaPoller(
         self._pika_engine,
         target,
         prefetch_count=self._pika_engine.rpc_listener_prefetch_count)
     listener.start()
     return base.PollStyleListenerAdapter(listener, batch_size,
                                          batch_timeout)
Ejemplo n.º 3
0
 def listen(self, target, on_incoming_callback, batch_size, batch_timeout):
     exchange = target.exchange or self._default_exchange
     listener = FakeListener(self._exchange_manager, [
         oslo_messaging.Target(
             topic=target.topic, server=target.server, exchange=exchange),
         oslo_messaging.Target(topic=target.topic, exchange=exchange)
     ])
     return base.PollStyleListenerAdapter(listener, on_incoming_callback,
                                          batch_size, batch_timeout)
Ejemplo n.º 4
0
 def listen(self, target, batch_size, batch_timeout):
     """Construct a Listener for the given target."""
     LOG.debug("Listen to %s", target)
     listener = ProtonListener(self)
     task = controller.SubscribeTask(target, listener)
     self._ctrl.add_task(task)
     task.wait()
     return base.PollStyleListenerAdapter(listener, batch_size,
                                          batch_timeout)
Ejemplo n.º 5
0
    def listen(self, target, batch_size, batch_timeout):
        """Listen to a specified target on a server side

        :param target: Message destination target
        :type target: oslo_messaging.Target
        """
        listener = zmq_server.ZmqServer(self, self.conf, self.matchmaker,
                                        target)
        return base.PollStyleListenerAdapter(listener, batch_size,
                                             batch_timeout)
Ejemplo n.º 6
0
    def listen_for_notifications(self, targets_and_priorities, pool,
                                 batch_size, batch_timeout):
        targets = [
            oslo_messaging.Target(
                topic='%s.%s' % (target.topic, priority),
                exchange=target.exchange)
            for target, priority in targets_and_priorities]
        listener = FakeListener(self._exchange_manager, targets, pool)

        return base.PollStyleListenerAdapter(listener, batch_size,
                                             batch_timeout)
Ejemplo n.º 7
0
 def listen_for_notifications(self, targets_and_priorities, pool,
                              batch_size, batch_timeout):
     listener = pika_drv_poller.NotificationPikaPoller(
         self._pika_engine,
         targets_and_priorities,
         prefetch_count=(
             self._pika_engine.notification_listener_prefetch_count),
         queue_name=pool)
     listener.start()
     return base.PollStyleListenerAdapter(listener, batch_size,
                                          batch_timeout)
Ejemplo n.º 8
0
    def listen_for_notifications(self, targets_and_priorities, pool,
                                 batch_size, batch_timeout):
        conn = self._get_connection(rpc_common.PURPOSE_LISTEN)

        listener = NotificationAMQPListener(self, conn)
        for target, priority in targets_and_priorities:
            conn.declare_topic_consumer(
                exchange_name=self._get_exchange(target),
                topic='%s.%s' % (target.topic, priority),
                callback=listener, queue_name=pool)
        return base.PollStyleListenerAdapter(listener, batch_size,
                                             batch_timeout)
Ejemplo n.º 9
0
    def listen_for_notifications(self, targets_and_priorities, pool,
                                 batch_size, batch_timeout):
        """Listen to a specified list of targets on a server side

        :param targets_and_priorities: List of pairs (target, priority)
        :type targets_and_priorities: list
        :param pool: Not used for zmq implementation
        :type pool: object
        """
        listener = zmq_server.ZmqNotificationServer(
            self, self.conf, self.matchmaker, targets_and_priorities)
        return base.PollStyleListenerAdapter(listener, batch_size,
                                             batch_timeout)
Ejemplo n.º 10
0
 def listen_for_notifications(self, targets_and_priorities, pool,
                              batch_size, batch_timeout):
     LOG.debug("Listen for notifications %s", targets_and_priorities)
     if pool:
         raise NotImplementedError('"pool" not implemented by '
                                   'this transport driver')
     listener = ProtonListener(self)
     for target, priority in targets_and_priorities:
         topic = '%s.%s' % (target.topic, priority)
         t = messaging_target.Target(topic=topic)
         self._ctrl.add_task(drivertasks.ListenTask(t, listener, True))
     return base.PollStyleListenerAdapter(listener, batch_size,
                                          batch_timeout)
Ejemplo n.º 11
0
    def listen(self, target, batch_size, batch_timeout):
        conn = self._get_connection(rpc_common.PURPOSE_LISTEN)

        listener = AMQPListener(self, conn)

        conn.declare_topic_consumer(exchange_name=self._get_exchange(target),
                                    topic=target.topic,
                                    callback=listener)
        conn.declare_topic_consumer(exchange_name=self._get_exchange(target),
                                    topic='%s.%s' %
                                    (target.topic, target.server),
                                    callback=listener)
        conn.declare_fanout_consumer(target.topic, listener)

        return base.PollStyleListenerAdapter(listener, batch_size,
                                             batch_timeout)
Ejemplo n.º 12
0
    def listen_for_notifications(self, targets_and_priorities, pool,
                                 batch_size, batch_timeout):
        conn = self._get_connection(rpc_common.PURPOSE_LISTEN)
        # NOTE(sileht): The application set batch_size, so we don't need to
        # prefetch more messages, especially for notifications. Notifications
        # queues can be really big when the consumer have disapear during a
        # long period, and when it come back, kombu/pyamqp will fetch all
        # messages it can. So we override the default qos prefetch value
        conn.connection.rabbit_qos_prefetch_count = batch_size

        listener = AMQPListener(self, conn)
        for target, priority in targets_and_priorities:
            conn.declare_topic_consumer(
                exchange_name=self._get_exchange(target),
                topic='%s.%s' % (target.topic, priority),
                callback=listener, queue_name=pool)
        return base.PollStyleListenerAdapter(listener, batch_size,
                                             batch_timeout)
Ejemplo n.º 13
0
    def listen_for_notifications(self, targets_and_priorities, pool,
                                 batch_size, batch_timeout):
        """Listen to a specified list of targets on Kafka brokers

        :param targets_and_priorities: List of pairs (target, priority)
                                       priority is not used for kafka driver
                                       target.exchange_target.topic is used as
                                       a kafka topic
        :type targets_and_priorities: list
        :param pool: consumer group of Kafka consumers
        :type pool: string
        """
        conn = self._get_connection(purpose=driver_common.PURPOSE_LISTEN)
        topics = set()
        for target, priority in targets_and_priorities:
            topics.add(target_to_topic(target, priority))

        conn.declare_topic_consumer(topics, pool)

        listener = KafkaListener(conn)
        return base.PollStyleListenerAdapter(listener, batch_size,
                                             batch_timeout)
Ejemplo n.º 14
0
 def listen_for_notifications(self, targets_and_priorities, pool,
                              batch_size, batch_timeout):
     """Construct a Listener for notifications on the given target and
     priority.
     """
     # TODO(kgiusti) should raise NotImplemented if not broker backend
     LOG.debug("Listen for notifications %s", targets_and_priorities)
     if pool:
         raise NotImplementedError('"pool" not implemented by '
                                   'this transport driver')
     listener = ProtonListener(self)
     # this is how the destination target is created by the notifier,
     # see MessagingDriver.notify in oslo_messaging/notify/messaging.py
     for target, priority in targets_and_priorities:
         topic = '%s.%s' % (target.topic, priority)
         # Sooo... the exchange is simply discarded? (see above comment)
         task = controller.SubscribeTask(Target(topic=topic),
                                         listener,
                                         notifications=True)
         self._ctrl.add_task(task)
         task.wait()
     return base.PollStyleListenerAdapter(listener, batch_size,
                                          batch_timeout)