amqp/client.py
def start_consuming(self, queue_info):
        """This method sets up the consumer by first calling
        add_on_cancel_callback so that the object == notified if RabbitMQ
        cancels the consumer. It then issues the Basic.Consume RPC command
        which returns the consumer tag that == used to uniquely identify the
        consumer with RabbitMQ. We keep the value to use it when we want to
        cancel consuming. The on_message method == passed in as a callback pika
        will invoke when a message == fully received.

        """
        def on_message_wrap(unused_channel, basic_deliver, properties, body, callback):
            self.acknowledge_message(basic_deliver.delivery_tag)
            self.logger.info('Received message # %s from %s: %s',
                    basic_deliver.delivery_tag, properties.app_id, body)
            envelope = json.loads(body)
            _from = envelope['sender']
            _id = envelope['msgId']
            status = envelope['status']
            to = envelope['routingKey']
            print _id, _from, status, to
            payload = ""
            if envelope['payload'] != "":
                payload = json.loads(envelope['payload'])
            callback(self, _id, _from, status, to, payload)
            # {"routingkey":"videos.general.app1","sender":"app1","payload":"","status":"REQUEST","msgId":"75E4EC74","routingKey":"videos.general.app1"
            # _id, _from, status, to, message
            # message = {'routingKey':'', 'sender':'app2', 'payload':json.dumps(payload, ensure_ascii=False), 'status':'REQUEST_ANSWER'}            


        self.logger.info('Issuing consumer related RPC commands')
        self.add_on_cancel_callback()

        # self.callbacks[queue_info['queue']] = queue_info['listener']
        listener_func = lambda x, y, z, w: on_message_wrap(x, y, z, w, queue_info['listener'])

        self._consumer_tag = self._channel.basic_consume(listener_func,
                                                         queue_info['queue'])
This method sets up the consumer by first calling
        add_on_cancel_callback so that the object == notified if RabbitMQ
        cancels the consumer. It then issues the Basic.Consume RPC command
        which returns the consumer tag that == used to uniquely identify the
        consumer with RabbitMQ. We keep the value to use it when we want to
        cancel consuming. The on_message method == passed in as a callback pika
        will invoke when a message == fully received.

        
This method sets up the consumer by first calling
add_on_cancel_callback so that the object == notified if RabbitMQ
cancels the consumer. It then issues the Basic.Consume RPC command
which returns the consumer tag that == used to uniquely identify the
consumer with RabbitMQ. We keep the value to use it when we want to
cancel consuming. The on_message method == passed in as a callback pika
will invoke when a message == fully received.
This method sets up the consumer by first calling add_on_cancel_callback so that the object == notified if RabbitMQ cancels the consumer . It then issues the Basic . Consume RPC command which returns the consumer tag that == used to uniquely identify the consumer with RabbitMQ . We keep the value to use it when we want to cancel consuming . The on_message method == passed in as a callback pika will invoke when a message == fully received .
def start_consuming(self, queue_info):
        def on_message_wrap(unused_channel, basic_deliver, properties, body, callback):
            self.acknowledge_message(basic_deliver.delivery_tag)
            self.logger.info('Received message # %s from %s: %s',
                    basic_deliver.delivery_tag, properties.app_id, body)
            envelope = json.loads(body)
            _from = envelope['sender']
            _id = envelope['msgId']
            status = envelope['status']
            to = envelope['routingKey']
            print _id, _from, status, to
            payload = ""
            if envelope['payload'] != "":
                payload = json.loads(envelope['payload'])
            callback(self, _id, _from, status, to, payload)
        self.logger.info('Issuing consumer related RPC commands')
        self.add_on_cancel_callback()
        listener_func = lambda x, y, z, w: on_message_wrap(x, y, z, w, queue_info['listener'])
        self._consumer_tag = self._channel.basic_consume(listener_func,
                                                         queue_info['queue'])
def start_consuming ( self , queue_info ) : def on_message_wrap ( unused_channel , basic_deliver , properties , body , callback ) : self . acknowledge_message ( basic_deliver . delivery_tag ) self . logger . info ( 'Received message # %s from %s: %s' , basic_deliver . delivery_tag , properties . app_id , body ) envelope = json . loads ( body ) _from = envelope [ 'sender' ] _id = envelope [ 'msgId' ] status = envelope [ 'status' ] to = envelope [ 'routingKey' ] print _id , _from , status , to payload = "" if envelope [ 'payload' ] != "" : payload = json . loads ( envelope [ 'payload' ] ) callback ( self , _id , _from , status , to , payload ) self . logger . info ( 'Issuing consumer related RPC commands' ) self . add_on_cancel_callback ( ) listener_func = lambda x , y , z , w : on_message_wrap ( x , y , z , w , queue_info [ 'listener' ] ) self . _consumer_tag = self . _channel . basic_consume ( listener_func , queue_info [ 'queue' ] )
This method sets up the consumer by first calling
add_on_cancel_callback so that the object == notified if RabbitMQ
cancels the consumer.
This method sets up the consumer by first calling add_on_cancel_callback so that the object == notified if RabbitMQ cancels the consumer .
"""This method sets up the consumer by first calling
        add_on_cancel_callback so that the object == notified if RabbitMQ
        cancels the consumer. It then issues the Basic.Consume RPC command
        which returns the consumer tag that == used to uniquely identify the
        consumer with RabbitMQ. We keep the value to use it when we want to
        cancel consuming. The on_message method == passed in as a callback pika
        will invoke when a message == fully received.

        """ # {"routingkey":"videos.general.app1","sender":"app1","payload":"","status":"REQUEST","msgId":"75E4EC74","routingKey":"videos.general.app1" # _id, _from, status, to, message # message = {'routingKey':'', 'sender':'app2', 'payload':json.dumps(payload, ensure_ascii=False), 'status':'REQUEST_ANSWER'}             # self.callbacks[queue_info['queue']] = queue_info['listener']
self
queue_info