Non Production Issue: After migrating from NServiceBus 3 to 4 and from VS2010 to 2012 I get this unhandled exception on my Program class when I start debugging. This exception was originated in NServiceBus.Host library.
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:
Stacktrace: NServiceBus.Host.exe!NServiceBus.Hosting.Windows.Program.Main(string[] args) Line 149 C#
app.config
<?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] <%X{auth}> - %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] <%X{auth}> - %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>
EndpointConfig.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());
}
}
}
Yes I’m using NServiceBus.Host process.
Already had found and tried this doc without success: NService Bus : "Unable to set the value for key: ScaleOut.UseSingleBrokerQueue."
Helpful information to include Product name: NServiceBus Version: 4.6.1