Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

Session based Filtering not happening in Receiver Azure Topic

$
0
0
I have been working on session enabled topic/subscription.

used following code to create Topic/Subscription,

   
 var subscriptionName = "TestSubscription";
            var topicName = "MyPartitionTopic";
            var namespaceManager = NamespaceManager.CreateFromConnectionString(RuntimeConfig.ConnectionStrings.PrimaryAzureSb);
            if (!namespaceManager.TopicExists(topicName))
            {
                var td = new TopicDescription(topicName);
                td.EnablePartitioning = true;
                namespaceManager.CreateTopic(td);
            }
            if (!namespaceManager.SubscriptionExists(topicName, subscriptionName))
            {
                var sd = new SubscriptionDescription(topicName, subscriptionName);
                sd.RequiresSession = true;
                namespaceManager.CreateSubscription(sd);
            }




 While receiving message in Receiver, filtering based on sessionId is not happening. I have used following code in Receiver,

     
void ReadMessage(string ConnectionStrings, string topicName, string subscriptionName, MessagingFactory messagingFactory, int batchcount)
        {
            int receivedMessages = 0;
            SubscriptionClient subsClient =
                messagingFactory.CreateSubscriptionClient(topicName, subscriptionName, ReceiveMode.ReceiveAndDelete);
            string sessionId = "sessionId1";
            subsClient.AcceptMessageSession(sessionId);

            IEnumerable<BrokeredMessage> messages = subsClient.PeekBatch(batchcount);
        }

For example:
I am sending message with following sessionId

Scenario 1. sessionId = sessionId1    
Scenario 2. sessionId = sessionId2

Receiver:  
Suppose I need to get messages which has only sessionId1,But using the above method it's simply returning the top batch of record(it may be sessionId1 or sessionId2)

1. how to get the exact matched message which has same sessionId?
2. whether any other feature is there apart from sessionId to achieve the same?

Thanks in Advance.

Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>