简体   繁体   English

在 Azure Function v1 中将 BrokeredMessage 移动到死信后出现 MessageLockLostException

[英]MessageLockLostException after moving BrokeredMessage to dead letter in Azure Function v1

I have a Azure Function v1 triggered via Service Bus topic.我有一个通过服务总线主题触发的 Azure Function v1。 If there happens any error, I put the BrokeredMessage to dead letter.如果发生任何错误,我会将 BrokeredMessage 放入死信。 It seems to work but after that I see following in Function's log streaming:它似乎有效,但之后我在函数的日志流中看到以下内容:

2019-11-19T10:49:31.382 [Error] MessageReceiver error (Action=Complete): Microsoft.ServiceBus.Messaging.MessageLockLostException: The lock supplied is invalid. 2019-11-19T10:49:31.382 [错误] MessageReceiver 错误(操作=完成):Microsoft.ServiceBus.Messaging.MessageLockLostException:提供的锁无效。 Either the lock expired, or the message has already been removed from the queue.锁已过期,或者消息已从队列中删除。

Here is what how I am putting BrokeredMessage to dead letter:以下是我将 BrokeredMessage 置于死信中的方式:

myBrokeredMessage.DeadLetter(deadLetterReason, exception.Message);
// after this I have tried following but doesn't work:
// 1. do nothing
// 2. myBrokeredMessage.Complete();
// 3. myBrokeredMessage.Abandon();

My Function is running fine.我的 Function 运行良好。 But after it has run and executed above code, that error appears to log streaming.但是在它运行并执行上述代码之后,该错误似乎会记录流式传输。 It seems doing what I want (putting BrokeredMessage to dead letter queue), but that error doesn't seem nice and I want to fix it.它似乎在做我想要的(将 BrokeredMessage 放入死信队列),但该错误似乎并不好,我想修复它。 I guess there is some kind of lock that I'm not handling correctly.我想我没有正确处理某种锁。

What should I do to fix that error?我应该怎么做才能修复该错误?

What should I do to fix that error?我应该怎么做才能修复该错误?

This is more of a warning than an error.这更像是一个警告而不是错误。 The way Functions are designed is that by default the function completes or dead-letters the message.函数的设计方式是默认情况下 function 完成或死信消息。 If you take control over what happens to the incoming message, Functions runtime doesn't it and still tries to apply the logic of completion as from its perspective there was no exception thrown from the user code and therefore the incoming message should be considered successfully processed and be completed.如果您控制传入消息发生的情况,Functions 运行时不会,它仍然会尝试应用完成逻辑,因为从它的角度来看,用户代码没有抛出异常,因此传入消息应该被视为已成功处理并完成。

With Functions 2.x there's a host setting that you could turn on to allow manual completion and disable the automatic completion.使用Functions 2.x有一个主机设置,您可以打开它以允许手动完成并禁用自动完成。 That is not available in v1.0, so you'll have to ignore the logged error.这在 v1.0 中不可用,因此您必须忽略记录的错误。 Or, alternatively, upgrade to 2.x.或者,升级到 2.x。

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

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