Azure队列发送消息方法到期

时间:2020-06-09 12:40:17

标签: azure-queues azure-function-app azure-sdk-python

Azure的新成员并测试Azure队列。我尝试使用Python SDK将消息发送到队列。这是我正在调用的方法

from azure.storage.queue import QueueServiceClient, QueueClient, QueueMessage

connectionstring=os.environ.get("connection_string")
queue_client = QueueClient.from_connection_string(connectionstring,queue_name)


msg_content={"MessageID":"AQ2","MessageContext":"This is a test Message"}

#set the visibility timeout to 10 seconds and time-to-live to 1 day (3600 minutes)
#The documentation seems to say its an integer . Is it day , minutes ,hours ,seconds ?

queue_client.send_message(msg_content,visibility_timeout=10,time_to_live=3600)

作为响应,我从队列得到的输出是

{'id': '90208a43-15d9-461e-a0ba-b12e02624d34',
 'inserted_on': datetime.datetime(2020, 6, 9, 12, 17, 57, tzinfo=<FixedOffset 0.0>),
 'expires_on': datetime.datetime(2020, 6, 9, 13, 17, 57, tzinfo=<FixedOffset 0.0>),
 'dequeue_count': None,
 'content': {'MessageID': 'AQ2',
 'MessageContext': 'This is a test Message'},
 'pop_receipt': '<hidingthistoavoidanydisclosures>',
 'next_visible_on': datetime.datetime(2020, 6, 9, 12, 18, 7, tzinfo=<FixedOffset 0.0>)}

现在,如果您在插入日期之后的一个小时内清楚地观察expires_,那就很好了。但是由于某种原因,该消息会立即移至中毒队列(如果未触及消息,通常应该在一个小时后发生。我不知道我要去哪里,请寻求有关如何正确设置到期时间以及为什么的帮助)立即将邮件移至中毒队列

1 个答案:

答案 0 :(得分:0)

生存时间以秒为单位。 这是doc for queue send message