2017-09-27 120 views
0

我试图在服务总线主题订阅中创建过滤器规则。无法添加Azure服务总线主题订阅过滤器规则

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) 
      { 

      } 
     } 

异常是从

client.AddRule(ruleDescription); 

让我试着删除以下行

client.RemoveRule(ruleName); 

和它的正常工作了拳头时间。但第二次应用程序运行,它会得到一个例外“消息实体已经存在”

但我需要删除现有的规则,并添加相同的规则,当启动订阅。

以下是完整的异常消息

Microsoft.ServiceBus.Messaging.MessagingException:该服务无法处理请求;请重试该操作。有关异常类型和适当异常处理的更多信息,请参阅http://go.microsoft.com/fwlink/?LinkId=761101 TrackingId:a08300d4-9f59-4455-8519-5410198ba444_G16,SystemTracker:vp-servicebus-poc:主题:test-topic2,时间戳:9/27/2017 9: 17:35 AM ---> System.ServiceModel.FaultException 1[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.ReconnectChannelFactory 1.RequestSessionChannel.RequestAsyncResult。 <> c.b__9_3(RequestAsyncResult thisPtr,IAsyncResult的R) 在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.Common.AsyncResult 1.End(IAsyncResult的asyncResult) 在Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory 1.RequestSessionChannel.EndRequest(IAsyncResult result) at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory 1.RedirectContainerSessionChannel.RequestAsyncResult。 <> c__DisplayClass8_1.b__4(RequestAsyncResult thisPtr,IAsyncResult的R) 在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.Common.AsyncResult 1.End(IAsyncResult的asyncResult) 在Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory 1.RedirectContainerSessionChannel.EndRequest(IAsyncResult result) at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory 1.RequestSessionChannel.RequestAsyncResult。 <> c.b__9_3(RequestAsyncResult thisPtr,IAsyncResult的R) 在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.Common.AsyncResult 1.End(IAsyncResult的asyncResult) 在Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory 1.RequestSessionChannel.EndRequest(IAsyncResult result) at Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult 1. <> c.b__18_3 (TIteratorAsyncResult thisPtr,IAsyncResult a) at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) ---从之前位置抛出异常的堆栈跟踪结束--- at Microsoft.ServiceBus.Common。 AsyncResult.End [TAsyncResult](IAsyncResult result) at Microsoft.ServiceBus.Messaging.Sbmp.SbmpSubscriptionClient.OnEndAddRule(IAsyncResult result) --- End of end ex在Microsoft.ServiceBus.Messaging.Sbmp.SbmpSubscriptionClient.OnEndAddRule(IAsyncResult的结果) ception堆栈跟踪--- 在Microsoft.ServiceBus.Messaging.SubscriptionClient.AddRule(RuleDescription介绍) 在ServiceBusReciver.ServiceBusReciverBuilder.InitRecivers()中G: \ Documents \ Visual Studio 2015 \ Projects \ ServiceBusReciver \ ServiceBusReciver \ ServiceBusReciverBuilder.cs:line 42

回答

0

在WindowsAzure.ServiceBus.dll版本中存在一个问题。 我将WindowsAzure.ServiceBus.dll的版本从4.1.3降级到4.1.2,它的工作非常完美。

编辑:这个问题又变得

+0

我只是想用4.1.3,它也为我工作... – Mikhail

+0

尝试一个简单的摄制代码,你就会有操作序列W/O循环。作为断点并检查你的实体。 –

+0

在这里,我创建了多个订户动态地添加过滤规则与foreach循环动态。有些时候它工作正常。但有些时候出现这个错误。这是零星的问题。 –

相关问题