Does NServiceBus support using Azure Service Bus sessions? The documentation looks quite extensive but I need an answer to this question before investing a lot of time reading through it all.
We have scenarios where we need both scale out AND local message ordering guarantees so we would need to leverage sessions in service bus to allow us to scale out to numerous consumers while ensuring that all messages with a given key (session id) are processed in order.
I am concerned that such transport specific features might not be supported by a framework that tries to accommodate a number of disparate messaging technologies.
The Azure Service Bus transport doesnât support sessions.
Service Bus Sessions will not help you if you require both the ordered processing and scale-out. A single session can only be processed by one consumer. Multiple consumers can process multiple sessions, but messages from the same session will only be processed by a single consumer.
Without knowing the scenario canât suggest an alternative but maybe what youâre trying to achieve can be modeled with Saga.
Thanks for the response Sean. Basically, we are looking to emulate behavior similar to how partitions are used in Apache Kafka. That is, take a stream of entity update events and consume them using multiple consumers, but provide a guarantee that at least all messages for the same entity instance (i.e. with the same id) are routed to the same consumer. We only need local ordering guarantees, not global ordering guarantees. We have had conversations with Microsoft and have a strategy for doing what we need to do with Service Bus, but we are also looking at available frameworks for putting a little bit more structure and consistency to our microservices architecture. We were looking at NServiceBus as one possible option, but needed to understand if the two things (Azure Service Bus Sessions and NServiceBus) could play together. It sounds like the answer is No ⌠or at least not right now.
We currently use Service Bus (.NET Core MS client) and things mostly work, but because we have multiple threads processing messages from the same topic, the concurrency sometimes results in our messages being processed out of order ⌠i.e. either lost updates or optimistic concurrency errors. This is particularly a problem when we are recovering from a Service Bus outage (even fairly short ones) because messages that were generated relatively far apart in time can sometimes be processed concurrently. Anyway, I think I think I have my answer, but if you have any thoughts, your inputs are certainly appreciated.
Weâre already using NServiceBus with Azure Service Bus transport in our Azure Function App and are running into the exact issue @wbailey1964 was concerned about.
In short, our Azure Function App is scaling out, causing messages related to the same âsessionâ (e.g., messages about the same Customer) to be processed in parallel across multiple instances. However, we need all messages concerning a given Customer to be processed sequentially by the same instance.
@SeanFeldman, do you have any thoughts on how this could be achieved using Sagas?
NServiceBus doesnât provide support for Sessions at the transport level AFAIK.
You could design a saga that would keep track of the processed messages associated with a given session, where messages would be correlated based on that customer identifier or whatever the data related to a âsessionâ.
You should upvote this feature request if you think support for sessions is a feature youâd like to see.