1

非生产问题:从 NServiceBus 3 迁移到 4 以及从 VS2010 迁移到 2012 后,当我开始调试时,我的 Program 类上出现了这个未处理的异常。此异常源自 NServiceBus.Host 库。

System.Configuration.ConfigurationErrorsException was unhandled
  HResult=-2146232062
  Message=Unable to set the value for key: ScaleOut.UseSingleBrokerQueue. The settings has been locked for modifications. Please move any configuration code earlier in the configuration pipeline
  Source=NServiceBus.Core
  BareMessage=Unable to set the value for key: ScaleOut.UseSingleBrokerQueue. The settings has been locked for modifications. Please move any configuration code earlier in the configuration pipeline
  Line=0
  StackTrace:
       at NServiceBus.Settings.SettingsHolder.EnsureWriteEnabled(String key) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Settings\SettingsHolder.cs:line 174
       at NServiceBus.Settings.SettingsHolder.Set(String key, Object value) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Settings\SettingsHolder.cs:line 57
       at NServiceBus.Settings.ScaleOutSettings.UseSingleBrokerQueue() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Settings\ScaleOutSettings.cs:line 18
       at NServiceBus.Hosting.Windows.Roles.Handlers.ServerRoleHandler.<ConfigureRole>b__0(ScaleOutSettings s) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Hosting.Windows\Roles\Handlers\ServerRoleHandler.cs:line 17
       at NServiceBus.Configure.ScaleOut(Action`1 customScaleOutSettings) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Configure.cs:line 185
       at NServiceBus.Hosting.Windows.Roles.Handlers.ServerRoleHandler.ConfigureRole(IConfigureThisEndpoint specifier) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Hosting.Windows\Roles\Handlers\ServerRoleHandler.cs:line 19
       at NServiceBus.Hosting.Roles.RoleManager.ConfigureBusForEndpoint(IConfigureThisEndpoint specifier) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Hosting\Roles\RoleManager.cs:line 67
       at NServiceBus.Hosting.GenericHost.PerformConfiguration() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Hosting\GenericHost.cs:line 189
       at NServiceBus.Hosting.GenericHost.Start() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Hosting\GenericHost.cs:line 86
       at NServiceBus.Hosting.Windows.WindowsHost.Start() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Hosting.Windows\WindowsHost.cs:line 55
       at NServiceBus.Hosting.Windows.Program.<>c__DisplayClasse.<Main>b__6(WindowsHost service) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Hosting.Windows\Program.cs:line 80
       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   at NServiceBus.Hosting.Windows.Program.Main(String[] args) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Hosting.Windows\Program.cs:line 151
  InnerException: 

堆栈跟踪:NServiceBus.Host.exe!NServiceBus.Hosting.Windows.Program.Main(string[] args) 第 149 行 C#

应用程序配置

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="TransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
    <section name="SecondLevelRetriesConfig" type="NServiceBus.Config.SecondLevelRetriesConfig, NServiceBus.Core" />
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="GripHandlers.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
    <section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
    <section name="AuditConfig" type="NServiceBus.Config.AuditConfig, NServiceBus.Core" />
  </configSections>
  <appSettings>
    <add key="DB" value="Data Source=Miguel;persist security info=True;user id=Miguel;password=Miguel" />
    <add key="ClientSettingsProvider.ServiceUri" value="" />
    <add key="LogDir" value="c:\Grip\OutputMessages" />
  </appSettings>
  <SecondLevelRetriesConfig Enabled="false" TimeIncrease="00:00:10" NumberOfRetries="3" />
  <TransportConfig NumberOfWorkerThreads="4" MaxRetries="5" />
  <UnicastBusConfig TimeoutManagerAddress="" DistributorControlAddress="" DistributorDataAddress="">
    <MessageEndpointMappings>
      <add Messages="Grip.Gateway.Events.Grip.ProcessedWithQualityIssuesEvent, Grip.Gateway.Events.Grip" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.External.ExternalPlacementDeletedEvent, Grip.Gateway.Events.External" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.External.ExternalPlacementModifiedEvent, Grip.Gateway.Events.External" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.External.ExternalTradeAddedEvent, Grip.Gateway.Events.External" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.External.ExternalTradeDeletedEvent, Grip.Gateway.Events.External" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.External.ExternalTradeModifiedEvent, Grip.Gateway.Events.External" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.Grip.GripGatewayNotifiedEvent, Grip.Gateway.Events.Grip" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.Grip.IntegrationExceptionEvent, Grip.Gateway.Events.Grip" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.Grip.AddAGripPlacementProcessedByService, Grip.Gateway.Events.Grip" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.Grip.PlacementAddedToGripEvent, Grip.Gateway.Events.Grip" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.Grip.PlacementModifiedInGripEvent, Grip.Gateway.Events.Grip" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.Grip.PlacementDeletedInGripEvent, Grip.Gateway.Events.Grip" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.Grip.TradeAddedToGripEvent, Grip.Gateway.Events.Grip" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.Grip.TradeModifiedInGripEvent, Grip.Gateway.Events.Grip" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.Grip.TradeDeletedInGripEvent, Grip.Gateway.Events.Grip" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.Grip.PlacementLinkedInGripEvent, Grip.Gateway.Events.Grip" Endpoint="Worker" />
      <add Messages="Grip.Gateway.Events.Grip.PlacementUnLinkedInGripEvent, Grip.Gateway.Events.Grip" Endpoint="Worker" />
    </MessageEndpointMappings>
  </UnicastBusConfig>
  <applicationSettings>
    <GripHandlers.Properties.Settings>
      <setting name="MonitorPerformance" serializeAs="String">
        <value>False</value>
      </setting>
      <setting name="EndpointSLA" serializeAs="String">
        <value>10</value>
      </setting>
    </GripHandlers.Properties.Settings>
  </applicationSettings>
  <MessageForwardingInCaseOfFaultConfig ErrorQueue="ERROR" />
  <log4net debug="false">
    <appender name="file" type="log4net.Appender.RollingFileAppender">
      <file>c:\Grip\Logs\GripHandlers.log</file>
      <maximumFileSize value="5MB" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n" />
      </layout>
    </appender>
    <appender name="console" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n" />
      </layout>
    </appender>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="file" />
      <appender-ref ref="console" />
    </root>
  </log4net>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="StructureMap" publicKeyToken="e60ad81abae3c223" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.6.4.0" newVersion="2.6.4.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="NServiceBus.Core" publicKeyToken="9fc386479f8a226c" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.6.0.0" newVersion="4.6.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="NServiceBus" publicKeyToken="9fc386479f8a226c" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.6.0.0" newVersion="4.6.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <AuditConfig QueueName="audit" />
</configuration>

端点配置.cs

    using System; 
    using System.Diagnostics.CodeAnalysis;
    using System.Transactions;
    using GripHandlers.Properties;
    using NServiceBus;
    using StructureMap;

    namespace GripHandlers 

    {

    [ExcludeFromCodeCoverage]
    public class EndpointConfig : IConfigureThisEndpoint, IWantCustomInitialization, AsA_Server
    {
        public void Init()
        {
            SetLoggingLibrary.Log4Net(() => log4net.Config.XmlConfigurator.Configure());

            var container = new Container(new GripHandlersRegistry());
            Configure.Transactions
               .Advanced(settings => settings.IsolationLevel(IsolationLevel.RepeatableRead))
               .Enable();

            //Tried this but no luck :(
            //Configure.ScaleOut(s => s.UseUniqueBrokerQueuePerMachine());

            Configure.With(AllAssemblies.Except("Oracle.DataAccess.dll"))
                .StructureMapBuilder(container)
                .UnicastBus()
                .UseTransport<Msmq>()
                .SetEndpointSLA(new TimeSpan(0, 0, Settings.Default.EndpointSLA))
                .EnablePerformanceCounters()
                .CreateBus()
                .Start(() => Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install());
        }
    }

}

是的,我正在使用 NServiceBus.Host 进程。

已经找到并尝试了这个文档但没有成功:NService Bus:“无法设置键的值:ScaleOut.UseSingleBrokerQueue。”

包含的有用信息产品名称:NServiceBus 版本:4.6.1

4

1 回答 1

3

从您发布的链接中:您是否尝试删除 CreateBus() 和 Start()?当您使用 ASA_Server 时,我认为不再需要这些。– 菲尔·桑德勒 2 天前

感谢菲尔。

于 2014-05-19T09:10:24.007 回答