本文整理汇总了Python中amqp.basic_message.Message.body方法的典型用法代码示例。如果您正苦于以下问题:Python Message.body方法的具体用法?Python Message.body怎么用?Python Message.body使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amqp.basic_message.Message
的用法示例。
在下文中一共展示了Message.body方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enqueue
# 需要导入模块: from amqp.basic_message import Message [as 别名]
# 或者: from amqp.basic_message.Message import body [as 别名]
def enqueue(self, tag, data, schedule = None, error_times=0, channel=None):
with self.open(channel):
self.setup_tag(tag)
msg = Message()
msg.properties['delivery_mode'] = 2
body = {'i': self.gensym(), 'c': data, 'e': error_times}
id = None
if schedule:
ttl = round_by_accuracy(get_millis_to_the_date(schedule), self.SCHEDULING_ACCURACY)
ttl1 = min(ttl, self.TTL_MAX)
stag = ('%s.%s' % (self.get_tag(tag, 'SCHEDULE'), str(ttl1), ))
self.channel.queue_declare(
queue=stag, durable=True, auto_delete=False,
arguments = { 'x-message-ttl' : ttl1, "x-dead-letter-exchange" : self.get_tag(tag, 'EXCHANGE') }
)
body['s'] = schedule.strftime(self.TIME_FORMAT)
msg.body = self.serializer(body)
id = self.channel.basic_publish(msg, routing_key=stag)
log(" [%s] Sent scheduled -> ttl: %s(%s) schedule: %s" % (body['i'], ttl1, ttl, body['s'], ))
else:
rtag = self.get_tag(tag, 'READY')
msg.body = self.serializer(body)
id = self.channel.basic_publish(msg, routing_key=rtag)
log(" [%s] Sent immediate -> tag: %s" % (body['i'], rtag))
return body['i']
示例2: check_proplist
# 需要导入模块: from amqp.basic_message import Message [as 别名]
# 或者: from amqp.basic_message.Message import body [as 别名]
def check_proplist(self, msg):
"""
Check roundtrip processing of a single object
"""
raw_properties = msg._serialize_properties()
new_msg = Message()
new_msg._load_properties(raw_properties)
new_msg.body = msg.body
self.assertEqual(msg, new_msg)