Azure Functions 2.0 中 ServiceBusTriggers 的 CompleteAsync 和 AbandonAsync 方法发生了什么
What happened to CompleteAsync and AbandonAsync method for ServiceBusTriggers in Azure Functions 2.0
我可以在 Azure Functions 1.0 中实现类似于以下内容的功能,但现在似乎 2.0 CompleteAsync()
和 AbandonAsync()
不再可用。
[FunctionName("Process")]
public static async System.Threading.Tasks.Task RunAsync(
[ServiceBusTrigger(
"%ServiceBus.Topic%", "%ServiceBus.Subscription%",
Connection = "AzureWebJobsServiceBus")]Message message, ILogger log) {
try {
MyMessageModel messageModel = message.GetBody<MyMessageModel>();
await DoAllTheThingsAsync().ConfigureAwait(false);
await message.CompleteAsync().ConfigureAwait(false);
} catch {
await message.AbandonAsync().ConfigureAwait(false);
throw;
}
}
是否已将控制权让给 Azure Function default for Peek Lock?
Azure 函数 1.X 使用了函数接收的 WindowsAzure.ServiceBus library for processing message. There, the methods like CompleteAsync()
and AbandonAsync()
were available with the BrokeredMessage 对象。
Where in Functions of version 2.X, Microsoft.Azure.ServiceBus library is being used, here BrokeredMessage is replaced by Message object, where no such methods are available. They are available only under QueueClient.
我可以在 Azure Functions 1.0 中实现类似于以下内容的功能,但现在似乎 2.0 CompleteAsync()
和 AbandonAsync()
不再可用。
[FunctionName("Process")]
public static async System.Threading.Tasks.Task RunAsync(
[ServiceBusTrigger(
"%ServiceBus.Topic%", "%ServiceBus.Subscription%",
Connection = "AzureWebJobsServiceBus")]Message message, ILogger log) {
try {
MyMessageModel messageModel = message.GetBody<MyMessageModel>();
await DoAllTheThingsAsync().ConfigureAwait(false);
await message.CompleteAsync().ConfigureAwait(false);
} catch {
await message.AbandonAsync().ConfigureAwait(false);
throw;
}
}
是否已将控制权让给 Azure Function default for Peek Lock?
Azure 函数 1.X 使用了函数接收的 WindowsAzure.ServiceBus library for processing message. There, the methods like CompleteAsync()
and AbandonAsync()
were available with the BrokeredMessage 对象。
Where in Functions of version 2.X, Microsoft.Azure.ServiceBus library is being used, here BrokeredMessage is replaced by Message object, where no such methods are available. They are available only under QueueClient.