不在NServiceBus中自动创建队列 [英] Not creating queues automatically in NServiceBus
问题描述
队列不存在或您没有足够的权限执行操作。
NServiceBus 2.6。
以下是我的配置:
var bus = Configure.With()
.Log4Net()
.NinjectBuilder()
.XmlSerializer()
.DefiningCommandsAs(t => typeof(ICommand).IsAssignableFrom(t))
.DefiningEventsAs(t => typeof(IEvent).IsAssignableFrom(t))
.DefiningMessagesAs(t => typeof(IMessage).IsAssignableFrom(t))
.MsmqTransport()
.DefineEndpointName(subscriber.input)
.IsTransactional(true)
.PurgeOnStartup(false)
.UnicastBus()
.LoadMessageHandlers()
.ImpersonateSender(false)
。 CreateBus()
.Start();
和
<结构>
< configSections>
< section name =MsmqTransportConfigtype =NServiceBus.Config.MsmqTransportConfig,NServiceBus.Core/>
< section name =UnicastBusConfigtype =NServiceBus.Config.UnicastBusConfig,NServiceBus.Core/>
< / configSections>
< MsmqTransportConfig ErrorQueue =errorNumberOfWorkerThreads =1MaxRetries =5/>
< UnicastBusConfig>
< MessageEndpointMappings>
< add Messages =MyEventsEndpoint =publisher.input/>
< / MessageEndpointMappings>
< / UnicastBusConfig>
< startup>
< supportedRuntime version =v4.0sku =。NETFramework,Version = v4.0/>
< / startup>
< / configuration>
我可以看到一个配置扩展方法来禁用自动创建队列,但没有启用它。
安装程序当您自主主机时,不会自动运行。请参阅 global.asax.cs in关于如何手动执行此操作的示例的asyncpages示例。
使用NServiceBus
使用NServiceBus。安装环境
...
总线= Configure.With()
.Log4Net()
.DefaultBuilder()
.XmlSerializer()
。 MsmqTransport()
.IsTransactional(false)
.PurgeOnStartup(false)
.UnicastBus()
.ImpersonateSender(false)
.CreateBus()
.Start(()=> Configure.Instance.ForInstallationOn< Windows>()。Install());
I'm running NServiceBus 3.0.0 rc2 but when I start the application (as local admin) without pre-creating the MSMQ's it errors with :
The queue does not exist or you do not have sufficient permissions to perform the operation.
This was not happening using NServiceBus 2.6.
Below is my config:
var bus = Configure.With()
.Log4Net()
.NinjectBuilder()
.XmlSerializer()
.DefiningCommandsAs(t => typeof(ICommand).IsAssignableFrom(t))
.DefiningEventsAs(t => typeof(IEvent).IsAssignableFrom(t))
.DefiningMessagesAs(t => typeof(IMessage).IsAssignableFrom(t))
.MsmqTransport()
.DefineEndpointName("subscriber.input")
.IsTransactional(true)
.PurgeOnStartup(false)
.UnicastBus()
.LoadMessageHandlers()
.ImpersonateSender(false)
.CreateBus()
.Start();
and
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
</configSections>
<MsmqTransportConfig ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyEvents" Endpoint="publisher.input" />
</MessageEndpointMappings>
</UnicastBusConfig>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
I can see a config extension method to disable automatic creation of queues but none for enabling it.
If I pre-create the queues it works fine.
Installers are not run automatically when you self host. Please see the global.asax.cs in the asyncpages sample for a example on how to do it manually.
using NServiceBus
using NServiceBus.Installation.Environments
...
Bus = Configure.With()
.Log4Net()
.DefaultBuilder()
.XmlSerializer()
.MsmqTransport()
.IsTransactional(false)
.PurgeOnStartup(false)
.UnicastBus()
.ImpersonateSender(false)
.CreateBus()
.Start(() => Configure.Instance.ForInstallationOn<Windows>().Install());
这篇关于不在NServiceBus中自动创建队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!