“尚未配置消息串行器”启动 NServiceBus 端点时出错

发布于 2024-08-31 08:22:58 字数 3273 浏览 3 评论 0原文

我的 GenericHost 托管服务无法启动,并显示以下消息:

2010-05-07 09:13:47,406 [1] FATAL NServiceBus.Host.Internal.GenericHost [(null)] <(null)> - System.InvalidOperationException:没有消息序列化器被配置 想通了。 在 d:\BuildAgent-02\work\672d81652eaca4e1\src\impl\unicast\NServiceBus.Unicast.Msmq\ 中的 NServiceBus.Unicast.Transport.Msmq.MsmqTransport.CheckConfiguration() MsmqTransport.cs:第 241 行 在 d:\BuildAgent-02\work\672d81652eaca4e1\src\impl\unicast\NServiceBus.Unicast.Msmq\MsmqTransport 中的 NServiceBus.Unicast.Transport.Msmq.MsmqTransport.Start() .cs:第 211 行 在 d:\BuildAgent-02\work\672d81652eaca4e1\src\unicast\NServiceBus.Uni 中的 NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start(ActionstartupAction) 演员\UnicastBus.cs:第 694 行 在 d:\BuildAgent-02\work\672d81652eaca4e1\src\unicast\NServiceBus.Unicast\UnicastBus.cs:l 中的 NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start() 内665 在 d:\BuildAgent-02\work\672d81652eaca4e1\src\host\NServiceBus.Host\Internal\GenericHost.cs 中的 NServiceBus.Host.Internal.GenericHost.Start() 处:第 77 行

我的端点配置如下所示:

public class ServiceEndpointConfiguration
    : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
    public void Init()
    {
        // build out persistence infrastructure
        var sessionFactory = Bootstrapper.InitializePersistence();

        // configure NServiceBus infrastructure
        var container = Bootstrapper.BuildDependencies(sessionFactory);

        // set up logging
        log4net.Config.XmlConfigurator.Configure();

        Configure.With()
            .Log4Net()
            .UnityBuilder(container)
            .XmlSerializer();
    }
}

和我的应用程序。配置看起来像:

<configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
    <section name="Logging" type="NServiceBus.Config.Logging, NServiceBus.Core" />
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
</configSections>

<Logging Threshold="DEBUG" />

<MsmqTransportConfig
    InputQueue="NServiceBus.ServiceInput"
    ErrorQueue="NServiceBus.Errors"
    NumberOfWorkerThreads="1"
    MaxRetries="2" />

<UnicastBusConfig
    DistributorControlAddress=""
    DistributorDataAddress=""
    ForwardReceivedMessagesTo="NServiceBus.Auditing">
    <MessageEndpointMappings>
        <!-- publishers don't need to set this for their own message types -->
    </MessageEndpointMappings>
</UnicastBusConfig>

<connectionStrings>
    <add name="Db" connectionString="Data Source=..." providerName="System.Data.SqlClient" />
</connectionStrings>

<log4net debug="true">
    <root>
        <level value="INFO"/>
    </root>
    <logger name="NHibernate">
        <level value="ERROR" />
    </logger>
</log4net>

这在过去是有效的,但在通用主机启动时似乎会失败。我的端点配置以及该服务的 app.config 如下。奇怪的是,在我的端点配置中,我指定使用 XmlSerializer 进行消息序列化。我在错误消息之前的控制台输出中没有看到任何其他错误。我缺少什么?

谢谢,史蒂夫

My GenericHost hosted service is failing to start with the following message:

2010-05-07 09:13:47,406 [1] FATAL NServiceBus.Host.Internal.GenericHost [(null)] <(null)> - System.InvalidOperationException: No message serializer has been con
figured.
at NServiceBus.Unicast.Transport.Msmq.MsmqTransport.CheckConfiguration() in d:\BuildAgent-02\work\672d81652eaca4e1\src\impl\unicast\NServiceBus.Unicast.Msmq\
MsmqTransport.cs:line 241
at NServiceBus.Unicast.Transport.Msmq.MsmqTransport.Start() in d:\BuildAgent-02\work\672d81652eaca4e1\src\impl\unicast\NServiceBus.Unicast.Msmq\MsmqTransport
.cs:line 211
at NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start(Action startupAction) in d:\BuildAgent-02\work\672d81652eaca4e1\src\unicast\NServiceBus.Uni
cast\UnicastBus.cs:line 694
at NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start() in d:\BuildAgent-02\work\672d81652eaca4e1\src\unicast\NServiceBus.Unicast\UnicastBus.cs:l
ine 665
at NServiceBus.Host.Internal.GenericHost.Start() in d:\BuildAgent-02\work\672d81652eaca4e1\src\host\NServiceBus.Host\Internal\GenericHost.cs:line 77

My endpoint configuration looks like:

public class ServiceEndpointConfiguration
    : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
    public void Init()
    {
        // build out persistence infrastructure
        var sessionFactory = Bootstrapper.InitializePersistence();

        // configure NServiceBus infrastructure
        var container = Bootstrapper.BuildDependencies(sessionFactory);

        // set up logging
        log4net.Config.XmlConfigurator.Configure();

        Configure.With()
            .Log4Net()
            .UnityBuilder(container)
            .XmlSerializer();
    }
}

And my app.config looks like:

<configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
    <section name="Logging" type="NServiceBus.Config.Logging, NServiceBus.Core" />
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
</configSections>

<Logging Threshold="DEBUG" />

<MsmqTransportConfig
    InputQueue="NServiceBus.ServiceInput"
    ErrorQueue="NServiceBus.Errors"
    NumberOfWorkerThreads="1"
    MaxRetries="2" />

<UnicastBusConfig
    DistributorControlAddress=""
    DistributorDataAddress=""
    ForwardReceivedMessagesTo="NServiceBus.Auditing">
    <MessageEndpointMappings>
        <!-- publishers don't need to set this for their own message types -->
    </MessageEndpointMappings>
</UnicastBusConfig>

<connectionStrings>
    <add name="Db" connectionString="Data Source=..." providerName="System.Data.SqlClient" />
</connectionStrings>

<log4net debug="true">
    <root>
        <level value="INFO"/>
    </root>
    <logger name="NHibernate">
        <level value="ERROR" />
    </logger>
</log4net>

This has worked in the past, but seems to be failing when the generic host starts. My endpoint configuration is below, along with the app.config for the service. What is strange is that in my endpoint configuration, I am specifying to use the XmlSerializer for message serialization. I don't see any other errors in the console output preceding the error message. What am I missing?

Thanks, Steve

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南街女流氓 2024-09-07 08:22:58

看来这是我自己的问题,尽管根据收到的错误消息我很难弄清楚这一点。我的所有消息都有一个基类:

public abstract class RequestMessage : IMessage {} 

最近,我创建了一个合作伙伴消息:

public abstract class ResponseMessage<TRequest> 
    where TRequest : RequestMessage {}

显然,当主机启动 IStartableBus 时,它会命中此通用消息类型,并且无法正确处理它。我只在使用 DefaultBuilder 运行时才真正看到了潜在的错误,而不是我在项目中使用的 UnityBuilder。它与泛型类型约束有关。我原以为这会起作用,但遗憾的是它没有。

问候,
史蒂夫

It looks like this was my own issue, though I had a hard time figuring that out based on the error message that I received. I have a base class for all of my messages:

public abstract class RequestMessage : IMessage {} 

Recently, I created a partner message:

public abstract class ResponseMessage<TRequest> 
    where TRequest : RequestMessage {}

Apparently, when the host was starting up the IStartableBus, it would hit this generic message type and would not handle it correctly. I only really saw the underlying error when running with the DefaultBuilder, rather than the UnityBuilder that I am using in my project. It had something to do with the generic type constraint. I had assumed that this would work, but sadly it did not.

Regards,
Steve

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文