简体   繁体   English

Azure功能和存储队列

[英]Azure Function and storage queue

I try to use Azure Storage Queue with azure function and I imagined it as very simple - get message from queue, processing, add new if necessary. 我尝试将Azure Storage Queue与azure函数一起使用,并且我想象它非常简单-从队列中获取消息,进行处理,并在必要时添加新消息。 But right now I get a mess, messages readd during my function processing current message (I have long process), sometimes I see messages in queue, which processed long time ago. 但是现在我一团糟,在函数处理当前消息时读取了消息(我的过程很长),有时我看到队列中的消息已经很久了。

Any way to say Azure Function: 可以用任何方式说Azure函数:

  1. Get message and delete from queue 获取消息并从队列中删除
  2. Processing message 正在处理讯息
  3. If success - nothing happened, if failure (exception) - readd current. 如果成功-什么都没有发生,如果失败(例外)-读取当前值。

Nothing more. 而已。 Without any complex logic. 没有任何复杂的逻辑。 Is it possible? 可能吗?

Based on comments above 根据以上评论

Your function is triggered by message in service bus. 服务总线中的消息触发了您的功能。 You process the message. 您处理该消息。 If you are happy and done in the given execution time (5 mins default) then message is marked as completed. 如果您满意并在给定的执行时间内完成(默认5分钟),则消息将标记为已完成。 If you are not happy , throw the exception. 如果您不满意,请抛出异常。 The function will consider message not completed and abandon it so it re-appears in the queue , however you retry count will keep on growing until it reaches the max value after which message is sent to dead letter queue. 该功能将认为消息未完成并放弃它,因此它会重新出现在队列中,但是您的重试计数将一直增长,直到达到最大值,然后将消息发送到死信队列。

Couple of points to note 需要注意的几点

If you don't throw the exception and process does it itself (due to some processing error) it still considers it abandoned message and will retry . 如果您不抛出异常并且进程自己执行(由于某些处理错误),则它仍将其视为已放弃的消息,并将重试。 However if function executes successfully without throwing any error but result is not what you want then throw ex your self. 但是,如果函数成功执行而没有引发任何错误,但是结果不是您想要的,则抛出您自己的异常。

Also in services bus increase the lock time to match the processing time of your function. 同样在服务总线中,增加锁定时间以匹配功能的处理时间。 eg function takes 5 mins to complete , but your message lock time in your services bus is 30 secs , the message will reappear in message queue while the other copy of message is still being processed by function. 例如,函数需要5分钟才能完成,但是您在服务总线中的消息锁定时间为30秒,消息将重新出现在消息队列中,而消息的另一个副本仍在由函数处理。 So increase your services bus message lock time that you consider is sufficient for function to complete the process. 因此,请增加您认为足以使功能完成该过程的服务总线消息锁定时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM