本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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'])