loekd/ServiceFabric.ServiceBus

ServiceBusQueueCommunicationListenerBase QueueClient - Subscribe to SessionId

Closed this issue · 3 comments

Is there a way to have a ServiceBusQueueCommunicationListener expose a property that can allow me to configure the listener to only listen/subscribe to messages from ASB queue with a particular SessionId or PartitionKey?

The property is this: QueueClient.AcceptMessageSession(string sessionId)

loekd commented

There's support for sessions: see the demo app for this.

As far as I know, partitioning is relevant when sending.

Thanks for the response. The issue I see is that, in ReceiveMessagesImplAsync, MessageSession is present to allow the handling of a particular session but it doesn't allow you to lock the client for messages for a particular session. What if I want my Sf service to only receive messages that contain SessionId = 'mySession' or PartitionKey = 'myPartitionKey'? I can't do that, unless I'm missing something. Again, I don't want my stateful service receiving any kind of messages from the queue(or topic), I want it to receive only messages that have a particular sessionId/partitionKey.

Let me frame the problem differently. For instance, take the AlphabetPartitions demo project (). There is a stateless service that sits in between the sender and the stateful service that manages a particular partition and its reliable store. Is there a way to remove this stateless service so that only the stateful service "listens" for particular sessionIds?

Perhaps that's a not a good idea. How would consumers then get that persisted data back from the reliable collections in that partition? I suppose they would need some sort of stateless broker like in the AlphabetPartitions example.

I apologize for the rambling. I'm trying to find ways to partition Sf services in a service bus system. My goal is to create a set of partitioned stateful services that maintain state for long running tasks without having a stateless layer in between brokering the communication.

loekd commented

I think that the best way to deliver messages to partitions is to create a subscription per service partition, and apply a correlation filter, on Label using the Service Partition Key. This way you avoid the problem of starvation that you get when using sessions, and are failing to receive from all sessions.

Querying individual partitions can be done by using the built-in reverse proxy. Provided the caller has intimate knowledge about the partitions. Otherwise, the stateless broker is required.