本文整理汇总了Python中amqp.basic_message.Message.properties['delivery_mode']方法的典型用法代码示例。如果您正苦于以下问题:Python Message.properties['delivery_mode']方法的具体用法?Python Message.properties['delivery_mode']怎么用?Python Message.properties['delivery_mode']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amqp.basic_message.Message
的用法示例。
在下文中一共展示了Message.properties['delivery_mode']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enqueue
# 需要导入模块: from amqp.basic_message import Message [as 别名]
# 或者: from amqp.basic_message.Message import properties['delivery_mode'] [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']