I have been trying to setup Rebus for Azure Service Bus, but I find it hard to find examples that fit my use case, or to construct a solution by myself.
I have multiple instances producing Message1
, each instance runs for a specific client, however they all produce instances of the message class Message1
. These messages need to be sent to ASB. Next, I have a lot of competing consumers for each tenant. In other words, for each tenant there are multiple consumers of Message1
but only one consumer can handle this message. This enables me to parallelize computationally heavy work.
Normally, I would create 1 queue in ASB per customer, therefore guaranteeing that messages from different customers will never get mixed up, or get executed more than once. Rebus however creates topics, therefore enabling multiple subscriptions. As far as my understanding goes, this means that all subscribers will get these messages (therefore causing duplication). Of course, one could filter on these messages. But I did not find any clear examples of this. Also this feels a bit unsafe; I cannot stress enough that these per-tenant data flows need to be separated.
What I managed to do up until now:
- Create separate topics per tenant
- Create separate (error-)queues per tenant, however, I am not sure how Rebus uses these queues, since messages are published on topics
In summary, my question is: how do I set up a scenario where the same message cannot be delivered twice, while also ensuring messages from one tenant will only be handled by consumers working for that tenant.