我試圖在服務總線主題訂閱中創建過濾器規則。無法添加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.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.AsyncResult
1.End(IAsyncResult的asyncResult) 在Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory1.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.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.AsyncResult
1.End(IAsyncResult的asyncResult) 在Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory1.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.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.AsyncResult
1.End(IAsyncResult的asyncResult) 在Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory1.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
我只是想用4.1.3,它也爲我工作... – Mikhail
嘗試一個簡單的攝製代碼,你就會有操作序列W/O循環。作爲斷點並檢查你的實體。 –
在這裏,我創建了多個訂戶動態地添加過濾規則與foreach循環動態。有些時候它工作正常。但有些時候出現這個錯誤。這是零星的問題。 –