コード例 #1
0
ファイル: test_librabbitmq.py プロジェクト: hakuokada/kombu
 def test_init(self):
     chan = Mock(name='channel')
     message = librabbitmq.Message(
         chan, {'prop': 42}, {'delivery_tag': 337}, 'body',
     )
     assert message.body == 'body'
     assert message.delivery_tag == 337
     assert message.properties['prop'] == 42
コード例 #2
0
 def test_init(self):
     chan = Mock(name='channel')
     message = librabbitmq.Message(
         chan,
         {'prop': 42},
         {'delivery_tag': 337},
         'body',
     )
     self.assertEqual(message.body, 'body')
     self.assertEqual(message.delivery_tag, 337)
     self.assertEqual(message.properties['prop'], 42)
コード例 #3
0
    def publish(self, rm):
        c = amqp.Connection(host=rm, userid="test", password="******")
        channel = c.channel()
        c.channel()

        qname = str(uuid.uuid4())
        message = amqp.Message(
            channel=channel,
            body='the quick brown fox jumps over the lazy dog',
            properties=dict(content_type='application/json',
                            content_encoding='utf-8'))

        channel.queue_declare(queue=qname, auto_delete=False)
        print("start: %s" % (time.ctime(time.time())))
        for i in range(0, 100):
            channel.basic_publish(message, routing_key=qname)
        print("end: %s" % (time.ctime(time.time())))
        c.close()