[英]NServiceBus 5 with RabbitMQ defining an EndpointName with single broker queue
我正在將自己的進程中托管的NServiceBus與RabbitMQ傳輸一起使用,並且剛剛從NServiceBus 4.6.5升級到NServiceBus 5.0.0。
以前,我的端點配置如下:
var queueName = ConfigurationManager.AppSettings["queuename"];
Configure.ScaleOut(s => s.UseSingleBrokerQueue());
Configure.Transactions.Disable();
Configure.Features.Enable<Sagas>();
Configure.Features.Disable<SecondLevelRetries>();
Configure.Serialization.Xml();
return
Configure.With(typeof(SomeClass).Assembly, typeof(RabbitMQ).Assembly)
.DefineEndpointName(queueName)
.DefaultBuilder()
.RavenPersistenceWithStore(DocumentStore.Value)
.DefiningCommandsAs(type => type.Namespace != null && type.Namespace.EndsWith("Contracts.Commands"))
.DefiningEventsAs(type => type.Namespace != null && type.Namespace.EndsWith("Contracts.Events"))
.DefiningMessagesAs(type => type.Namespace != null && type.Namespace.EndsWith("Contracts.Messages"))
.RijndaelEncryptionService()
.UseTransport<RabbitMQ>()
.PurgeOnStartup(false)
.UnicastBus()
.RunHandlersUnderIncomingPrincipal(false)
.ImpersonateSender(false)
.LoadMessageHandlers()
.DisableTimeoutManager()
.RavenSagaPersister()
.RavenSubscriptionStorage()
.UseRavenTimeoutPersister()
.CreateBus()
.Start
(() => {
DependencyManager.ConfigureServiceBusDependencies();
Configure.Instance.LicensePath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NServiceBus-Licence.xml"));
Configure.Instance.ForInstallationOn<Windows>().Install();
});
效果很好,並創建了一個名為“ some.appropriate.queue.name”的隊列,該隊列取自我的app.config文件。
但是,在升級到NServiceBus 5.0.0.0時,我使用了新的配置api並按如下方式配置了我的端點:
var queueName = ConfigurationManager.AppSettings["queuename"];
var configuration = new BusConfiguration();
configuration.EndpointName(queueName);
configuration.LicensePath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NServiceBus-Licence.xml"));
configuration.ScaleOut().UseSingleBrokerQueue();
configuration.Transactions().Disable();
configuration.EnableFeature<Sagas>();
configuration.DisableFeature<SecondLevelRetries>();
configuration.UseSerialization<XmlSerializer>();
configuration.UsePersistence<RavenDBPersistence>()
.SetDefaultDocumentStore(DocumentStore.Value)
.For(Storage.Sagas, Storage.Subscriptions, Storage.Timeouts);
configuration.Conventions()
.DefiningCommandsAs(type => type.Namespace != null && type.Namespace.EndsWith("Contracts.Commands"));
configuration.Conventions().DefiningEventsAs(type => type.Namespace != null && type.Namespace.EndsWith("Contracts.Events"));
configuration.Conventions()
.DefiningMessagesAs(type => type.Namespace != null && type.Namespace.EndsWith("Contracts.Messages"));
configuration.RijndaelEncryptionService();
configuration.PurgeOnStartup(false);
configuration.UseTransport<RabbitMQTransport>();
configuration.RegisterComponents(DependencyManager.ConfigureServiceBusDependencies);
configuration.AssembliesToScan
(typeof(SomeClass).Assembly, typeof(RabbitMQTransport).Assembly);
configuration.EnableInstallers();
var bus = Bus.Create(configuration);
現在,它創建了一個名為“ some.appropriate.queue.name.MyLaptopName”的隊列。 因此,即使我已將橫向擴展選項配置為使用單個代理隊列,NServiceBus仍將機器名稱添加到隊列名稱的末尾。
這是一個錯誤,還是4.6.5中的錯誤和機器名稱的工作方式應始終添加到隊列名稱的末尾,即使在使用單個代理隊列時也是如此?
非常感謝對此問題的任何幫助。
為了在擴展時無縫地支持回調和pubsub,我們必須將v2.0.0更改為具有單獨的回調接收器。 您可以通過致電將其關閉
configuration.UseTransport<RabbitMQTransport>()
.DisableCallbackReceiver();
這是完整的doco頁面,詳細解釋了所有這些內容:
http://docs.particular.net/nservicebus/rabbitmq/configuration-api
.SingleBrokerQueue()被忽略,您可以安全地刪除它。 (將在NServiceBus核心的v6中廢棄)
在查看了github上針對NServiceBus報告的問題后,我在https://github.com/Particular/NServiceBus/issues/2412上進行了介紹 ,該狀態指出ScaleOut()。x已過時,將從6.0.0中刪除。
因此,我從配置中刪除了該配置,以查看是否可以解決我的問題。 它不是:(但是讓我思考它的含義。因此,實際上應該始終指定計算機名稱,甚至是本地主機。
所以我改變了這一行:
configuration.EndpointName(queueName);
對此:
configuration.EndpointName(string.Format("{0}@localhost", queueName));
然后端點在不添加機器名稱后綴的情況下創建隊列。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.