当前位置: 首页>>代码示例>>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;未经允许,请勿转载。