带有 Azure Function 的基于会话的服务总线
Session based service bus with Azure Function
我在 Azure 上使用会话队列,当我将一些数据推送到队列时,我编写了一个 Azure 函数来触发。
请注意,我已经创建了基于 statefull/session 的队列。
问题是当我将数据推送到队列时出现
之类的错误
The listener for function 'xxx' was unable to start.
Microsoft.ServiceBus: It is not possible for an entity that requires
sessions to create a non-sessionful message receiver
所以我的问题是我不能在 queue/topic 的会话中使用函数吗?
2020 年更新:
在您的 function.json
中设置 isSessionsEnabled
属性。
这是一个常见问题,但目前 Web Jobs SDK 和 Azure Functions 不支持服务总线会话。见 WebJobs SDK issue; unfortunately there's no progress 3 years after it was created. Add a +1 in Azure Functions issue.
我认为现在可以使用测试包 Microsoft.Azure.WebJobs.Extensions.ServiceBus/3.1.0-beta2
。
public static void Run([ServiceBusTrigger("core-test-queue1-sessions",
Connection = "AzureWebJobsServiceBus",
IsSessionsEnabled = true)]string myQueueItem,
IMessageSession messageSession,
ILogger log)
您还可以在 host.json 中指定新的 SessionHandlerOptions 部分:
{
"version": "2.0",
"extensions": {
"serviceBus": {
"SessionHandlerOptions":
{
"MaxAutoRenewDuration": "00:01:00",
"MessageWaitTimeout": "00:05:00",
"MaxConcurrentSessions": 16,
"AutoComplete": true,
}
}
}
}
https://github.com/azure/azure-webjobs-sdk/issues/529#issuecomment-491113458
您需要在消费者AF的function.json中指定属性 "IsSessionsEnabled": true
我在 Azure 上使用会话队列,当我将一些数据推送到队列时,我编写了一个 Azure 函数来触发。
请注意,我已经创建了基于 statefull/session 的队列。
问题是当我将数据推送到队列时出现
之类的错误The listener for function 'xxx' was unable to start. Microsoft.ServiceBus: It is not possible for an entity that requires sessions to create a non-sessionful message receiver
所以我的问题是我不能在 queue/topic 的会话中使用函数吗?
2020 年更新:
在您的 function.json
中设置 isSessionsEnabled
属性。
这是一个常见问题,但目前 Web Jobs SDK 和 Azure Functions 不支持服务总线会话。见 WebJobs SDK issue; unfortunately there's no progress 3 years after it was created. Add a +1 in Azure Functions issue.
我认为现在可以使用测试包 Microsoft.Azure.WebJobs.Extensions.ServiceBus/3.1.0-beta2
。
public static void Run([ServiceBusTrigger("core-test-queue1-sessions",
Connection = "AzureWebJobsServiceBus",
IsSessionsEnabled = true)]string myQueueItem,
IMessageSession messageSession,
ILogger log)
您还可以在 host.json 中指定新的 SessionHandlerOptions 部分:
{
"version": "2.0",
"extensions": {
"serviceBus": {
"SessionHandlerOptions":
{
"MaxAutoRenewDuration": "00:01:00",
"MessageWaitTimeout": "00:05:00",
"MaxConcurrentSessions": 16,
"AutoComplete": true,
}
}
}
}
https://github.com/azure/azure-webjobs-sdk/issues/529#issuecomment-491113458
您需要在消费者AF的function.json中指定属性 "IsSessionsEnabled": true