Session based service bus with Azure Function

纵然是瞬间 提交于 2019-12-07 15:57:32

问题


I am using session queue on Azure and when I push some data on queue,I write one Azure function to trigger.

Please note that I have created statefull/session based queue.

The problem is when I push data to queue at that moment I got error like

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

So my question is am I not able to use function with queue/topic with session?


回答1:


This is a common ask, but currently Web Jobs SDK, and thus Azure Functions, don't support Service Bus sessions. See WebJobs SDK issue; unfortunately there's no progress 3 years after it was created. Add a +1 in Azure Functions issue.




回答2:


I think its actually possible now, using the beta package 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)

Also you can specify new SessionHandlerOptions section in host.json:

{
    "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



来源:https://stackoverflow.com/questions/51298378/session-based-service-bus-with-azure-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!