0

I'm trying to create filter rule in service bus topic subscription.

 foreach(var reciver in recivers)
        {
            try
            {
                var client = SubscriptionClient.CreateFromConnectionString(ServiceBusConnectionString, reciver.TopicName, reciver.SubscriptionName);

                string ruleName = "customRule2";
                client.RemoveRule(ruleName);

                var filter = reciver.Reciver.GetFilter();
                var ruleDescription = new RuleDescription(ruleName, filter);

                client.AddRule(ruleDescription);
                client.RemoveRule("$Default");

                client.OnMessage((msg) => {
                    reciver.Reciver.Recive(msg);
                });                    
            }
            catch(Exception ex)
            {

            }
        }

Exception is getting from

client.AddRule(ruleDescription);

I tried with removing following line

client.RemoveRule(ruleName);

and it's working properly for fist time. But second time application runs, it's getting an exception "The messaging entity already exist"

But I need to remove existing rule and add the same rule when initiating the subscription.

Following is the full exception message

Microsoft.ServiceBus.Messaging.MessagingException: The service was unable to process the request; please retry the operation. For more information on exception types and proper exception handling, please refer to http://go.microsoft.com/fwlink/?LinkId=761101 TrackingId:a08300d4-9f59-4455-8519-5410198ba444_G16, SystemTracker:vp-servicebus-poc:Topic:test-topic2, Timestamp:9/27/2017 9:17:35 AM ---> System.ServiceModel.FaultException1[System.ServiceModel.ExceptionDetail]: The service was unable to process the request; please retry the operation. For more information on exception types and proper exception handling, please refer to http://go.microsoft.com/fwlink/?LinkId=761101 TrackingId:a08300d4-9f59-4455-8519-5410198ba444_G16, SystemTracker:vp-servicebus-poc:Topic:test-topic2, Timestamp:9/27/2017 9:17:35 AM at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.ThrowIfFaultMessage(Message wcfMessage) at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.HandleMessageReceived(IAsyncResult result) --- End of stack trace from previous location where exception was thrown --- at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.EndRequest(IAsyncResult result) at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory1.RequestSessionChannel.RequestAsyncResult.<>c.b__9_3(RequestAsyncResult thisPtr, IAsyncResult r) at Microsoft.ServiceBus.Messaging.IteratorAsyncResult1.StepCallback(IAsyncResult result) --- End of stack trace from previous location where exception was thrown --- at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) at Microsoft.ServiceBus.Common.AsyncResult1.End(IAsyncResult asyncResult) at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory1.RequestSessionChannel.EndRequest(IAsyncResult result) at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory1.RedirectContainerSessionChannel.RequestAsyncResult.<>c__DisplayClass8_1.b__4(RequestAsyncResult thisPtr, IAsyncResult r) at Microsoft.ServiceBus.Messaging.IteratorAsyncResult1.StepCallback(IAsyncResult result) --- End of stack trace from previous location where exception was thrown --- at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) at Microsoft.ServiceBus.Common.AsyncResult1.End(IAsyncResult asyncResult) at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory1.RedirectContainerSessionChannel.EndRequest(IAsyncResult result) at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory1.RequestSessionChannel.RequestAsyncResult.<>c.b__9_3(RequestAsyncResult thisPtr, IAsyncResult r) at Microsoft.ServiceBus.Messaging.IteratorAsyncResult1.StepCallback(IAsyncResult result) --- End of stack trace from previous location where exception was thrown --- at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) at Microsoft.ServiceBus.Common.AsyncResult1.End(IAsyncResult asyncResult) at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory1.RequestSessionChannel.EndRequest(IAsyncResult result) at Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult1.<>c.b__18_3(TIteratorAsyncResult thisPtr, IAsyncResult a) at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) --- End of stack trace from previous location where exception was thrown --- at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) at Microsoft.ServiceBus.Messaging.Sbmp.SbmpSubscriptionClient.OnEndAddRule(IAsyncResult result) --- End of inner exception stack trace --- at Microsoft.ServiceBus.Messaging.Sbmp.SbmpSubscriptionClient.OnEndAddRule(IAsyncResult result) at Microsoft.ServiceBus.Messaging.SubscriptionClient.AddRule(RuleDescription description) at ServiceBusReciver.ServiceBusReciverBuilder.InitRecivers() in G:\Documents\Visual Studio 2015\Projects\ServiceBusReciver\ServiceBusReciver\ServiceBusReciverBuilder.cs:line 42

Sithira Pathirana
  • 588
  • 1
  • 8
  • 26

1 Answers1

0

There was a issue in WindowsAzure.ServiceBus.dll version. I downgraded the version of WindowsAzure.ServiceBus.dll from 4.1.3 to 4.1.2 it's working perfect.

EDIT : This issue is getting again

Sithira Pathirana
  • 588
  • 1
  • 8
  • 26
  • Try a simpler repro code where you'd have a sequence of operations w/o a loop. As breakpoints and inspect your entities. – Sean Feldman Sep 27 '17 at 13:36
  • Here I'm creating multiple subscribers dynamically and adding filter rule dynamically withing the foreach loop. Some times it is working fine. But some times getting this error. This is sporadic issue. – Sithira Pathirana Sep 28 '17 at 02:22