Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
937 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...