Exemple #1
0
 def create_worker(self, topic, proxy, pool_name):
     """Create a worker that calls a method in a proxy object"""
     proxy_cb = rpc_amqp.ProxyCallback(
         self.conf, proxy,
         rpc_amqp.get_connection_pool(self.conf, Connection))
     self.proxy_callbacks.append(proxy_cb)
     self.declare_topic_consumer(topic, proxy_cb, pool_name)
Exemple #2
0
    def join_consumer_pool(self, callback, pool_name, topic,
                           exchange_name=None):
        """Register as a member of a group of consumers for a given topic from
        the specified exchange.

        Exactly one member of a given pool will receive each message.

        A message will be delivered to multiple pools, if more than
        one is created.
        """
        callback_wrapper = rpc_amqp.CallbackWrapper(
            conf=self.conf,
            callback=callback,
            connection_pool=rpc_amqp.get_connection_pool(self.conf,
                                                         Connection),
        )
        self.proxy_callbacks.append(callback_wrapper)

        consumer = TopicConsumer(conf=self.conf,
                                 session=self.session,
                                 topic=topic,
                                 callback=callback_wrapper,
                                 name=pool_name,
                                 exchange_name=exchange_name)

        self._register_consumer(consumer)
        return consumer
Exemple #3
0
 def create_worker(self, topic, proxy, pool_name):
     """Create a worker that calls a method in a proxy object"""
     proxy_cb = rpc_amqp.ProxyCallback(
         self.conf, proxy,
         rpc_amqp.get_connection_pool(self.conf, Connection))
     self.proxy_callbacks.append(proxy_cb)
     self.declare_topic_consumer(topic, proxy_cb, pool_name)
Exemple #4
0
    def join_consumer_pool(self,
                           callback,
                           pool_name,
                           topic,
                           exchange_name=None):
        """Register as a member of a group of consumers for a given topic from
        the specified exchange.

        Exactly one member of a given pool will receive each message.

        A message will be delivered to multiple pools, if more than
        one is created.
        """
        callback_wrapper = rpc_amqp.CallbackWrapper(
            conf=self.conf,
            callback=callback,
            connection_pool=rpc_amqp.get_connection_pool(
                self.conf, Connection),
        )
        self.proxy_callbacks.append(callback_wrapper)
        self.declare_topic_consumer(
            queue_name=pool_name,
            topic=topic,
            exchange_name=exchange_name,
            callback=callback_wrapper,
        )
Exemple #5
0
    def create_consumer(self, topic, proxy, fanout=False):
        """Create a consumer that calls a method in a proxy object"""
        proxy_cb = rpc_amqp.ProxyCallback(self.conf, proxy, rpc_amqp.get_connection_pool(self.conf, Connection))

        if fanout:
            self.declare_fanout_consumer(topic, proxy_cb)
        else:
            self.declare_topic_consumer(topic, proxy_cb)
Exemple #6
0
    def create_worker(self, topic, proxy, pool_name):
        """Create a worker that calls a method in a proxy object"""
        proxy_cb = rpc_amqp.ProxyCallback(self.conf, proxy, rpc_amqp.get_connection_pool(self.conf, Connection))

        consumer = TopicConsumer(self.conf, self.session, topic, proxy_cb, name=pool_name)

        self._register_consumer(consumer)

        return consumer
Exemple #7
0
    def create_consumer(self, topic, proxy, fanout=False):
        """Create a consumer that calls a method in a proxy object"""
        proxy_cb = rpc_amqp.ProxyCallback(
            self.conf, proxy,
            rpc_amqp.get_connection_pool(self.conf, Connection))

        if fanout:
            self.declare_fanout_consumer(topic, proxy_cb)
        else:
            self.declare_topic_consumer(topic, proxy_cb)
Exemple #8
0
    def create_consumer(self, topic, proxy, fanout=False):
        """Create a consumer that calls a method in a proxy object"""
        proxy_cb = rpc_amqp.ProxyCallback(self.conf, proxy, rpc_amqp.get_connection_pool(self.conf, Connection))

        if fanout:
            consumer = FanoutConsumer(self.conf, self.session, topic, proxy_cb)
        else:
            consumer = TopicConsumer(self.conf, self.session, topic, proxy_cb)

        self._register_consumer(consumer)

        return consumer
Exemple #9
0
    def create_worker(self, topic, proxy, pool_name):
        """Create a worker that calls a method in a proxy object"""
        proxy_cb = rpc_amqp.ProxyCallback(
            self.conf, proxy,
            rpc_amqp.get_connection_pool(self.conf, Connection))

        consumer = TopicConsumer(self.conf, self.session, topic, proxy_cb,
                                 name=pool_name)

        self._register_consumer(consumer)

        return consumer
Exemple #10
0
    def create_consumer(self, topic, proxy, fanout=False):
        """Create a consumer that calls a method in a proxy object"""
        proxy_cb = rpc_amqp.ProxyCallback(
            self.conf, proxy,
            rpc_amqp.get_connection_pool(self.conf, Connection))

        if fanout:
            consumer = FanoutConsumer(self.conf, self.session, topic, proxy_cb)
        else:
            consumer = TopicConsumer(self.conf, self.session, topic, proxy_cb)

        self._register_consumer(consumer)

        return consumer
Exemple #11
0
def notify(conf, context, topic, msg, envelope):
    """Sends a notification event on a topic."""
    return rpc_amqp.notify(conf, context, topic, msg,
                           rpc_amqp.get_connection_pool(conf, Connection),
                           envelope)
Exemple #12
0
def fanout_cast_to_server(conf, context, server_params, topic, msg):
    """Sends a message on a fanout exchange to a specific server."""
    return rpc_amqp.fanout_cast_to_server(
        conf, context, server_params, topic, msg,
        rpc_amqp.get_connection_pool(conf, Connection))
Exemple #13
0
def fanout_cast(conf, context, topic, msg):
    """Sends a message on a fanout exchange without waiting for a response."""
    return rpc_amqp.fanout_cast(
        conf, context, topic, msg,
        rpc_amqp.get_connection_pool(conf, Connection))
Exemple #14
0
def fanout_cast_to_server(conf, context, server_params, topic, msg):
    """Sends a message on a fanout exchange to a specific server."""
    return rpc_amqp.fanout_cast_to_server(
        conf, context, server_params, topic, msg,
        rpc_amqp.get_connection_pool(conf, Connection))
Exemple #15
0
def call(conf, context, topic, msg, timeout=None):
    """Sends a message on a topic and wait for a response."""
    return rpc_amqp.call(conf, context, topic, msg, timeout,
                         rpc_amqp.get_connection_pool(conf, Connection))
Exemple #16
0
def create_connection(conf, new=True):
    """Create a connection"""
    return rpc_amqp.create_connection(
        conf, new, rpc_amqp.get_connection_pool(conf, Connection))
Exemple #17
0
def multicall(conf, context, topic, msg, timeout=None):
    """Make a call that returns multiple times."""
    return rpc_amqp.multicall(conf, context, topic, msg, timeout,
                              rpc_amqp.get_connection_pool(conf, Connection))
Exemple #18
0
def create_connection(conf, new=True):
    """Create a connection"""
    return rpc_amqp.create_connection(
        conf, new,
        rpc_amqp.get_connection_pool(conf, Connection))
Exemple #19
0
def fanout_cast(conf, context, topic, msg):
    """Sends a message on a fanout exchange without waiting for a response."""
    return rpc_amqp.fanout_cast(conf, context, topic, msg,
                                rpc_amqp.get_connection_pool(conf, Connection))
Exemple #20
0
def multicall(conf, context, topic, msg, timeout=None):
    """Make a call that returns multiple times."""
    return rpc_amqp.multicall(
        conf, context, topic, msg, timeout,
        rpc_amqp.get_connection_pool(conf, Connection))
Exemple #21
0
def notify(conf, context, topic, msg):
    """Sends a notification event on a topic."""
    return rpc_amqp.notify(conf, context, topic, msg,
                           rpc_amqp.get_connection_pool(conf, Connection))
Exemple #22
0
def call(conf, context, topic, msg, timeout=None):
    """Sends a message on a topic and wait for a response."""
    return rpc_amqp.call(
        conf, context, topic, msg, timeout,
        rpc_amqp.get_connection_pool(conf, Connection))