12

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

Zenuka
  • 3,110
  • 28
  • 39
  • Hi @Zenuka, I have this problem too. Can I ask how you resolved it in the end? – Jason Steele Jan 31 '16 at 17:40
  • @JasonSteele, 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: http://www.cloudcasts.net/devguide/Default.aspx?id=13030 – Zenuka Feb 09 '16 at 17:36

2 Answers2

2

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

  • so can we get ALL the messages that are part of the same session? how? – Alex Gordon Jul 10 '19 at 02:57
  • this is not helpful. can you forward all messages with a specific session to a queue? – Alex Gordon Jul 10 '19 at 14:15
  • 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. – Pawel Haracz Jul 11 '19 at 06:52
  • More details about session you find on msdn [link](https://learn.microsoft.com//en-us/azure/service-bus-messaging/message-sessions) 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." – Pawel Haracz Jul 11 '19 at 06:53
  • 1
    Just noting for anyone coming looking that this functionality is now released and no longer in beta. – Bobson Feb 18 '20 at 00:18
0

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.

Matthew Steven Monkan
  • 8,170
  • 4
  • 53
  • 71