當前位置: 首頁>>代碼示例>>Python>>正文


Python Message.create方法代碼示例

本文整理匯總了Python中amqpstorm.Message.create方法的典型用法代碼示例。如果您正苦於以下問題:Python Message.create方法的具體用法?Python Message.create怎麽用?Python Message.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在amqpstorm.Message的用法示例。


在下文中一共展示了Message.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_functional_publish_and_change_app_id

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_functional_publish_and_change_app_id(self):
        self.channel.confirm_deliveries()
        self.channel.queue.declare(self.queue_name)
        message = Message.create(self.channel,
                                 body=self.message)
        message.app_id = 'travis-ci'
        message.publish(self.queue_name)

        message = self.channel.basic.get(self.queue_name, no_ack=True)

        # Check original app_id
        self.assertEqual(message.app_id, 'travis-ci')

        # Assign Property app_id
        app_id = 'travis-ci-2'.encode('utf-8')
        message.app_id = app_id

        # Check that it was set correctly.
        self.assertEqual(message.properties['app_id'], app_id)

        # Get Property Correlation Id
        correlation_id = message.correlation_id

        # Publish Message
        message.publish(routing_key=self.queue_name)

        # Sleep for 0.01s to make sure RabbitMQ has time to catch up.
        time.sleep(0.01)

        payload = self.channel.basic.get(self.queue_name, no_ack=True)
        self.assertEqual(payload.app_id, app_id.decode('utf-8'))
        self.assertEqual(payload.correlation_id, correlation_id)
        self.assertIsInstance(payload.properties['app_id'], str)
        self.assertIsInstance(payload.properties['correlation_id'], str)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:36,代碼來源:generic_tests.py

示例2: test_message_correlation_id_custom_value

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_correlation_id_custom_value(self):
        correlation_id = str(uuid.uuid4())

        message = Message.create(None, '')
        message.correlation_id = correlation_id

        self.assertEqual(correlation_id, message.correlation_id)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:9,代碼來源:message_tests.py

示例3: test_message_content_encoding_custom_value

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_content_encoding_custom_value(self):
        content_encoding = 'gzip'

        message = Message.create(None, '')
        message.content_encoding = content_encoding

        self.assertEqual(content_encoding, message.content_encoding)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:9,代碼來源:message_tests.py

示例4: test_message_reply_to_custom_value

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_reply_to_custom_value(self):
        reply_to = str(uuid.uuid4())

        message = Message.create(None, '')
        message.reply_to = reply_to

        self.assertEqual(reply_to, message.reply_to)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:9,代碼來源:message_tests.py

示例5: test_message_priority_three

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_priority_three(self):
        priority = 3

        message = Message.create(None, '')
        message.priority = priority

        self.assertEqual(priority, message.priority)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:9,代碼來源:message_tests.py

示例6: publish_message

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
def publish_message(channel, body, queue, expiration="600"):
    # Create the message with a expiration (time to live).
    message = Message.create(channel, body,
                             properties={"expiration": expiration})

    # Publish the message to a queue.
    message.publish(queue)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:9,代碼來源:publish_message_with_expiration.py

示例7: test_message_delivery_mode_two

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_delivery_mode_two(self):
        delivery_mode = 2

        message = Message.create(None, '')
        message.delivery_mode = delivery_mode

        self.assertEqual(delivery_mode, message.delivery_mode)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:9,代碼來源:message_tests.py

示例8: test_message_app_id_custom_value

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_app_id_custom_value(self):
        app_id = 'my-app'

        message = Message.create(None, '')
        message.app_id = app_id

        self.assertEqual(app_id, message.app_id)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:9,代碼來源:message_tests.py

示例9: test_message_timestamp_custom_value

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_timestamp_custom_value(self):
        dt = datetime.now()

        message = Message.create(None, '')
        message.timestamp = dt

        self.assertEqual(dt, message.timestamp)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:9,代碼來源:message_tests.py

示例10: test_message_content_type_custom_value

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_content_type_custom_value(self):
        content_type = 'application/json'

        message = Message.create(None, '')
        message.content_type = content_type

        self.assertEqual(content_type, message.content_type)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:9,代碼來源:message_tests.py

示例11: test_message_not_redelivered

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_not_redelivered(self):
        message = Message.create(body='',
                                 channel=FakeChannel())
        message._method = {
            'redelivered': False
        }

        self.assertFalse(message.redelivered)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:10,代碼來源:message_tests.py

示例12: test_message_redelivered_is_none

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_redelivered_is_none(self):
        message = Message.create(body='',
                                 channel=FakeChannel())
        message._method = {
            'redelivered': None
        }

        self.assertIsNone(message.redelivered)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:10,代碼來源:message_tests.py

示例13: test_message_delivery_tag_is_none

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_delivery_tag_is_none(self):
        message = Message.create(body='',
                                 channel=FakeChannel())
        message._method = {
            'delivery_tag': None
        }

        self.assertIsNone(message.delivery_tag)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:10,代碼來源:message_tests.py

示例14: test_functional_publish_fail_recover

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_functional_publish_fail_recover(self):
        self.channel.queue.declare(self.queue_name)
        self.channel.confirm_deliveries()

        message = Message.create(self.channel, self.message)
        self.assertRaises(AMQPChannelError, message.publish, self.message,
                          exchange=self.exchange_name, mandatory=True)
        self.assertFalse(self.channel.is_open)
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:10,代碼來源:generic_tests.py

示例15: test_message_id_custom_value

# 需要導入模塊: from amqpstorm import Message [as 別名]
# 或者: from amqpstorm.Message import create [as 別名]
    def test_message_id_custom_value(self):
        message_id = 'my-message-1'

        message = Message.create(None, '')
        message.message_id = message_id

        self.assertEqual(message_id, message.properties['message_id'])
        self.assertEqual(message_id, message._properties['message_id'])
開發者ID:eandersson,項目名稱:amqpstorm,代碼行數:10,代碼來源:message_tests.py


注:本文中的amqpstorm.Message.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。