1

我有一个从 2.6 升级到 3.2.7 后无法启动的 NServicebus 项目,端点如下所示:

namespace Customer.Project.SchemaImportService
{
    public class SchemaImportEndpoint : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
    {
    private IContainer _container;

    public void Init()
    {
        log4net.Config.XmlConfigurator.Configure();
        SetupStructureMap();

        Configure.With()
            .Log4Net()
            .StructureMapBuilder(_container)
            .DisableTimeoutManager()
            .XmlSerializer()
            .CreateBus();
    }

    private void SetupStructureMap()
    {
        // implementation omitted
    }
}

此外,app.config 看起来像这样:

<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
<section name="Logging" type="NServiceBus.Config.Logging, NServiceBus.Core" />
</configSections>
<MsmqTransportConfig NumberOfWorkerThreads="1" MaxRetries="5" />
<Logging Threshold="DEBUG" /> 
<log4net debug="true"> <!-- logging details omitted -->  </log4net>
<MessageForwardingInCaseOfFaultConfig ErrorQueue="Customer.Project.SchemaImportService.Error" />

当我调试项目时,我启动了 NServicebus.Host.exe 文件,我尝试切换配置文件(生产、集成和 Lite),结果相同。

给出的异常(离开 init 语句后)如下所示:

Message: "Exception when starting endpoint, error has been logged. Reason: Object reference not set to an instance of an object."
Source: NserviceBus.Host

StackTrace: at NServiceBus.Hosting.GenericHost.Start() in     c:\TeamCity\buildAgent\work\nsb.master_7\src\hosting\NServiceBus.Hosting\GenericHost.cs:line 45
at NServiceBus.Hosting.Windows.WindowsHost.Start() in     c:\TeamCity\buildAgent\work\nsb.master_7\src\hosting\NServiceBus.Hosting.Windows\WindowsHost.cs:line 56
   at NServiceBus.Hosting.Windows.Program.<>c__DisplayClass8.<Main>b__4(WindowsHost service) in     c:\TeamCity\buildAgent\work\nsb.master_7\src\hosting\NServiceBus.Hosting.Windows\Program.cs:line 97
   at Topshelf.Internal.ControllerDelegates`1.StartActionObject(Object obj) in     c:\Projects\TopShelfForNSB\src\Topshelf\Internal\ControllerDelegates.cs:line 18
   at Topshelf.Internal.IsolatedServiceControllerWrapper`1.<>c__DisplayClass2.    <set_StartAction>b__1(TService service) in    c:\Projects\TopShelfForNSB\src\Topshelf\Internal\IsolatedServiceControllerWrapper.cs:line 65
   at Topshelf.Internal.ServiceController`1.<.cctor>b__1(ServiceController`1 sc) in c:\Projects\TopShelfForNSB\src\Topshelf\Internal\ServiceController.cs:line 35
   at Magnum.StateMachine.LambdaAction`1.Execute(T instance, Event event, Object parameter) in :line 0
   at Magnum.StateMachine.EventActionList`1.Execute(T stateMachine, Event event, Object     parameter) in :line 0

以下行记录在我的日志文件中:

INFO  2012-08-21 13:25:24,881 18494ms RoleManager            gureBusForEndpoint - Role NServiceBus.AsA_Server configured
DEBUG 2012-08-21 13:25:25,124 18738ms TransactionalTransport DebugFormat        - Setting throttling to: [1] message/s per second, sleep between receiving message: [800]
FATAL 2012-08-21 13:25:25,158 18772ms GenericHost            Start              - System.NullReferenceException: Object reference not set to an instance of an object.
   at NServiceBus.Unicast.Transport.Transactional.TransactionalTransport.NServiceBus.Unicast.Transport.ITransport.Start(Address address)
   at NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start(Action startupAction)
   at NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start()
   at NServiceBus.Hosting.GenericHost.Start() in  c:\TeamCity\buildAgent\work\nsb.master_7\src\hosting\NServiceBus.Hosting\GenericHost.cs:line 32

我可以提供的最后一点信息(但也许是最重要的一个)是,如果我删除所有消息队列,则不会自动重新创建主队列。

这些私有队列被创建:

customer.project.schemaimportservice.error
customer.project.schemaimportservice.retries

但是

customer.project.schemaimportservice

队列丢失,即使它与我的命名空间匹配(请参阅帖子顶部)。

我究竟做错了什么?我必须在版本 3.2.7 中手动配置消息队列名称吗?

4

1 回答 1

1

我必须在 Init 类的 Configure.With() 部分下包含 .MsMqTransport() 。

于 2012-08-21T13:11:25.183 回答