会话的Azure WebJob ServiceBusTrigger

Azure WebJob ServiceBusTrigger for Sessions
2020-10-18
  •  译文(汉语)
  •  原文(英语)

我知道可以从服务总线队列中接收消息,例如:

public static void ProcessQueueMessage([ServiceBusTrigger("inputqueue")] string message, TextWriter logger)

但是,还有一种方法可以通过触发属性来接收会话吗?像ServiceBusSessionTrigger一样?

通常,人们会接受这样的会议:

var session = queueClient.AcceptMessageSession();

但是我更希望WebJob SDK处理一次可以处理多个会话的方式.

编辑: 似乎当前不支持此功能:有关功能请求,请参见github

编辑2:似乎他们正在为此

速聊1:
嗨@Zenuka,我也有这个问题.请问您最后如何解决?
速聊2:
,我不知道我曾经使用哪个博客/教程/视频来实现它,例如"var session = queueClient.AcceptMessageSession()",但我认为您可以将其用作指南:cloudcasts.net/devguide/Default.aspx?id = 13030
解决过程1

当前,您无法通过触发器属性接收会话,但是存在GitHub功能请求.如果这是许多人认为有用的东西,那么将其烘焙到核心ServiceBus程序集中就很有意义.

速聊1:
您如何遍历会话中的所有消息?
解决过程2

3.1.0-beta3版本中的此nuget Microsoft.Azure.WebJobs.Extensions.ServiceBus支持Azure功能中的会话.当您安装此nuget时,您将可以像下面的代码一样使用它 [ServiceBusTrigger("testsessionqueue", Connection = "serviceBusConnectionString", IsSessionsEnabled = true)]

在那里您可以找到nuget:Nuget ,这是一个github问题:github

请记住,它仍然是测试版

速聊1:
那么我们可以获取属于同一会话的所有消息吗?怎么样?
速聊2:
这没有帮助.您可以将具有特定会话的所有消息转发到队列吗?
速聊3:
您需要为邮件提供sessionId作为属性,并确保您的队列或主题支持连接,然后Azure服务总线将使用会话功能.支持会话的Azure功能只是一个终结点,因此它仅按FIFO顺序获取消息.
速聊4:
有关在msdn 链接上找到的会话的更多详细信息,这是关于连接的主要句子:"在具有会话意识的队列或订阅上,当至少有一条带有会话SessionID的消息时,会话就存在了.一旦存在会话,就没有定义从理论上讲,可以从今天开始接收消息,即一年后的下一条消息;如果SessionId匹配,则从服务总线角度来看,会话是相同的."
速聊5:
只是注意到任何来此功能已发布且不再处于beta中的人.

I know it's possible to recieve messages from a service bus queue like:

public static void ProcessQueueMessage([ServiceBusTrigger("inputqueue")] string message, TextWriter logger)

But is there also a way to to receive a session via a trigger attribute? Something like ServiceBusSessionTrigger?

Normally one would accept a session like this:

var session = queueClient.AcceptMessageSession();

But I'd prefer the WebJob SDK to handle how multiple sessions at once can be processed.

Edit: Seems that this currently isn't supported: see github for feature request

Edit 2: Seems they are working on this

Talk1:
Hi @Zenuka, I have this problem too. Can I ask how you resolved it in the end?
Talk2:
, I don't know which blog/tutorial/video I used to implement it like 'var session = queueClient.AcceptMessageSession()' but I think you could use this as a guideline: cloudcasts.net/devguide/Default.aspx?id=13030
Solutions1

Currently you cannot receive a session via a trigger attribute, but there is a GitHub feature request. If this is something that many people would find useful, it would make sense baked into the core ServiceBus assembly.

Talk1:
how do you iterate through all messages in a session?
Solutions2

this nuget Microsoft.Azure.WebJobs.Extensions.ServiceBus in 3.1.0-beta3 version support session in azure function. when you install this nuget, you will be able to use it like the code below [ServiceBusTrigger("testsessionqueue", Connection = "serviceBusConnectionString", IsSessionsEnabled = true)]

there you can find nuget : Nuget and it's a github issue: github

Please bear in mind that it's still a beta

Talk1:
so can we get ALL the messages that are part of the same session? how?
Talk2:
this is not helpful. can you forward all messages with a specific session to a queue?
Talk3:
you need to provide sessionId to your message as property and ensure that your queue or topic support a seesion, then Azure service bus will use the session feature. Azure functions which support session is only an endpoint, so it only grabs messages in a FIFO order.
Talk4:
More details about session you find on msdn link it's a main sentence about seesion : "On session-aware queues or subscriptions, sessions come into existence when there is at least one message with the session's SessionId. Once a session exists, there is no defined time or API for when the session expires or disappears. Theoretically, a message can be received for a session today, the next message in a year's time, and if the SessionId matches, the session is the same from the Service Bus perspective."
Talk5:
Just noting for anyone coming looking that this functionality is now released and no longer in beta.
转载于:https://stackoverflow.com/questions/30773632/azure-webjob-servicebustrigger-for-sessions

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入