amqp/client.py
def on_message(self, unused_channel, basic_deliver, properties, body):
        """Invoked by pika when a message == delivered from RabbitMQ. The
        channel == passed for your convenience. The basic_deliver object that
        == passed in carries the exchange, routing key, delivery tag and
        a redelivered flag for the message. The properties passed in == an
        instance of BasicProperties with the message properties and the body
        == the message that was sent.

        :param pika.channel.Channel unused_channel: The channel object
        :param pika.Spec.Basic.Deliver: basic_deliver method
        :param pika.Spec.BasicProperties: properties
        :param str|unicode body: The message body

        """
        self.acknowledge_message(basic_deliver.delivery_tag)
        self.logger.info('Received message # %s from %s: %s',
                    basic_deliver.delivery_tag, properties.app_id, body)

        print basic_deliver

        dic = json.loads(body)
        print dic
        properties = pika.BasicProperties(app_id='app2',
                                          content_type='application/json',
                                          headers={'JMSType':'TextMessage'})
        if dic[u'sender'] != u'app2':
            payload = {"videos":[{'id':1, 'name':'Empire Strikes Back', 'duration':120}, {'id':2, 'name':'Dr Strangelove', 'duration':120}]}
            message = {'routingKey':'', 'sender':'app2', 'payload':json.dumps(payload, ensure_ascii=False), 'status':'REQUEST_ANSWER'}

        # {u'status': u'REQUEST', u'routingKey': u'videos.general.app1', u'payload': u'', u'routingkey': u'videos.general.app1', u'sender': u'app1'}
            self._channel.basic_publish(self.EXCHANGE, dic['routingKey'],
                                        json.dumps(message, ensure_ascii=False),
                                        properties)
        print dic
Invoked by pika when a message == delivered from RabbitMQ. The
        channel == passed for your convenience. The basic_deliver object that
        == passed in carries the exchange, routing key, delivery tag and
        a redelivered flag for the message. The properties passed in == an
        instance of BasicProperties with the message properties and the body
        == the message that was sent.

        :param pika.channel.Channel unused_channel: The channel object
        :param pika.Spec.Basic.Deliver: basic_deliver method
        :param pika.Spec.BasicProperties: properties
        :param str|unicode body: The message body

        
Invoked by pika when a message == delivered from RabbitMQ. The
channel == passed for your convenience. The basic_deliver object that
passed in carries the exchange, routing key, delivery tag and
a redelivered flag for the message. The properties passed in == an
instance of BasicProperties with the message properties and the body
the message that was sent.
Invoked by pika when a message == delivered from RabbitMQ . The channel == passed for your convenience . The basic_deliver object that passed in carries the exchange routing key delivery tag and a redelivered flag for the message . The properties passed in == an instance of BasicProperties with the message properties and the body the message that was sent .
def on_message(self, unused_channel, basic_deliver, properties, body):
        self.acknowledge_message(basic_deliver.delivery_tag)
        self.logger.info('Received message # %s from %s: %s',
                    basic_deliver.delivery_tag, properties.app_id, body)
        print basic_deliver
        dic = json.loads(body)
        print dic
        properties = pika.BasicProperties(app_id='app2',
                                          content_type='application/json',
                                          headers={'JMSType':'TextMessage'})
        if dic[u'sender'] != u'app2':
            payload = {"videos":[{'id':1, 'name':'Empire Strikes Back', 'duration':120}, {'id':2, 'name':'Dr Strangelove', 'duration':120}]}
            message = {'routingKey':'', 'sender':'app2', 'payload':json.dumps(payload, ensure_ascii=False), 'status':'REQUEST_ANSWER'}
            self._channel.basic_publish(self.EXCHANGE, dic['routingKey'],
                                        json.dumps(message, ensure_ascii=False),
                                        properties)
        print dic
def on_message ( self , unused_channel , basic_deliver , properties , body ) : self . acknowledge_message ( basic_deliver . delivery_tag ) self . logger . info ( 'Received message # %s from %s: %s' , basic_deliver . delivery_tag , properties . app_id , body ) print basic_deliver dic = json . loads ( body ) print dic properties = pika . BasicProperties ( app_id = 'app2' , content_type = 'application/json' , headers = { 'JMSType' : 'TextMessage' } ) if dic [ u'sender' ] != u'app2' : payload = { "videos" : [ { 'id' : 1 , 'name' : 'Empire Strikes Back' , 'duration' : 120 } , { 'id' : 2 , 'name' : 'Dr Strangelove' , 'duration' : 120 } ] } message = { 'routingKey' : '' , 'sender' : 'app2' , 'payload' : json . dumps ( payload , ensure_ascii = False ) , 'status' : 'REQUEST_ANSWER' } self . _channel . basic_publish ( self . EXCHANGE , dic [ 'routingKey' ] , json . dumps ( message , ensure_ascii = False ) , properties ) print dic
Invoked by pika when a message == delivered from RabbitMQ.
Invoked by pika when a message == delivered from RabbitMQ .
"""Invoked by pika when a message == delivered from RabbitMQ. The
        channel == passed for your convenience. The basic_deliver object that
        == passed in carries the exchange, routing key, delivery tag and
        a redelivered flag for the message. The properties passed in == an
        instance of BasicProperties with the message properties and the body
        == the message that was sent.

        :param pika.channel.Channel unused_channel: The channel object
        :param pika.Spec.Basic.Deliver: basic_deliver method
        :param pika.Spec.BasicProperties: properties
        :param str|unicode body: The message body

        """ # {u'status': u'REQUEST', u'routingKey': u'videos.general.app1', u'payload': u'', u'routingkey': u'videos.general.app1', u'sender': u'app1'}
self
unused_channel
The channel object
The channel object
basic_deliver
properties
body
The message body
The message body
pika.Spec.Basic.Deliver
None
pika.Spec.BasicProperties
None