0
votes

I'm wondering how I can get certain behavior with Azure Service Bus topics and subscriptions. For our app we have 1 topic and many subscriptions. Subscriptions use filters. When a message is published it can be filtered by one or more subscriptions.

We already use peeklock and maxconcurrentcalls of 1, but that does not prevent multiple consumers from running in parallel.

What we want to do is let multiple consumer instances subscribe to the same subscription. But * Only one instance may process a message at a given time. (in that way the order of processing is garanteed). * We hope that those instances are load balanced.

So, at the end we want to load balance our consumers while keeping message order and no parallel processing.

How can we achieve this?


Edit: I want to make sure that I have failover of the consumers. And hopefully the consumers are load balanced: I don't want that all active instances are on 1 machine.

1
if ordered processing is that important, why use multiple consumers? Now all work is processed sequential, with all consumers waiting for the next oneErik Oppedijk
I've editted the question: I want to have failover of consumers. But they use the same datastore. So I need ordering of messages and no parallel processing.Michiel Overeem
Failover of a consumer should be build on the consumer side, Azure has no idea of the state of your consumer.Erik Oppedijk
If you post an answer, I can accept it, because I think you might be right.Michiel Overeem

1 Answers

2
votes

Multiple consumers will work in parallel, so it is very difficult to let just one work and have the others standby.

The solution is a single started consumer.

Failover of a consumer should be build on the consumer side, Azure has no idea of the state of your consumer. So a second machine should check if the first one is still working, if not, take over, and make sure to lock the first one out in case this machine starts consuming again.