1

I have a multi-tenancy system and need to guarantee FIFO (first-in-first-out) processing of queued messages by tenant, i.e. each tenant would get its own MaxConcurrentCalls = 1.

To be done in Azure and technology not fixed.

I know this could be achieved by creating a separate WebJob for each tenant, but that limits scalability.

Are there any other ways to achieve such a behaviour?

Benjamin E.
  • 5,042
  • 5
  • 38
  • 65

1 Answers1

3

Since you mentioned Service Bus, I suggest

  • Use Service Bus Queues or Topics with Sessions enabled
  • Assign session identifiers based on tenant ID

This way you should be able to process messages one-by-one and in-order per tenant, but multiple tenants in parallel.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107
  • +1 Note that with this approach you'd be able to scale out for growing number of tenants. Per tenant there will be only a single consumer (known limitation when processing messages with Sessions). – Sean Feldman Aug 24 '17 at 14:44
  • This seems to be the right approach, but Microsoft is behind on all feature requests for this on WebJobs and Functions (I see you in the github discussion). Where do you run your code? VM/WorkerRole or do you have it working in WebJobs? – Benjamin E. Aug 25 '17 at 09:50
  • @BenjaminE. We are running Web Jobs without using Web Job SDK triggers. Just a console app reading sessions itself. – Mikhail Shilkov Aug 25 '17 at 10:11