Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
996 views
in Technique[技术] by (71.8m points)

azureservicebus - Azure Functions: Service Bus Messages Processed Twice

We have several Azure Function (1.0) apps with a ServiceBus trigger. We are experiencing a sporadic problem where messages are picked up and processed twice, which causes huge problems.

Our sample code looks like this:

[FunctionName("CreateFile")]
public static async Task Run([ServiceBusTrigger(CreateFileTask.topic, "default", Connection = "Queue.ConnectionString")]string mySbMsg, ILogger log)
{
...

The most recent time this occurred, the message was retrieved and started processing at 7:00pm. At 7:03pm, the message was again retrieved and processed in parallel. Both processes finished successfully, which resulted in the creation of two files.

This problem doesn't happen frequently (maybe once every two months), but it is a huge headache when it does.

How can we prevent this from occurring in the future?

question from:https://stackoverflow.com/questions/65830451/azure-functions-service-bus-messages-processed-twice

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If the original message was processed at 7:00pm and duplicate processing took place in parallel at 7:03pm, your lock duration might be shorter than the maximum message processing time. As a result of that, a message could and would be processed more than once. Except one execution would log a failure to complete the message when the other would succeed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...