From 374f76b70c291b81b5954ad83f96c6ca4865e7a2 Mon Sep 17 00:00:00 2001 From: John Simons Date: Mon, 7 Jan 2013 14:33:56 +1100 Subject: [PATCH 1/7] HandleCurrentMessageLater on workers causes workers to send extra ready messages, fixes #851 Conflicts: src/NServiceBus.Core/Distributor/Config/WorkerInitializer.cs src/NServiceBus.Core/Distributor/MsmqWorkerAvailabilityManager/MsmqWorkerAvailabilityManager.cs src/NServiceBus.Core/Distributor/ReadyMessages/ReadyMessageSender.cs src/NServiceBus.Core/Unicast/UnicastBus.cs --- .../ReadyMessages/ReadyMessageSender.cs | 9 ++++++++- src/unicast/NServiceBus.Unicast/UnicastBus.cs | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/distributor/NServiceBus.Distributor/ReadyMessages/ReadyMessageSender.cs b/src/distributor/NServiceBus.Distributor/ReadyMessages/ReadyMessageSender.cs index 4f8ac779840..31b270fd9f0 100644 --- a/src/distributor/NServiceBus.Distributor/ReadyMessages/ReadyMessageSender.cs +++ b/src/distributor/NServiceBus.Distributor/ReadyMessages/ReadyMessageSender.cs @@ -25,8 +25,15 @@ public void Run() EndpointTransport.FinishedMessageProcessing += (a, b) => { - if (((IBus)Bus).CurrentMessageContext.Headers.ContainsKey(NServiceBus.Headers.Retries)) + if (Bus.CurrentMessageContext.Headers.ContainsKey(NServiceBus.Headers.Retries)) + { return; + } + + if (Bus.HandleCurrentMessageLaterCalled) + { + return; + } SendReadyMessage(1); }; diff --git a/src/unicast/NServiceBus.Unicast/UnicastBus.cs b/src/unicast/NServiceBus.Unicast/UnicastBus.cs index edda4ec33dc..d8e5362ae61 100644 --- a/src/unicast/NServiceBus.Unicast/UnicastBus.cs +++ b/src/unicast/NServiceBus.Unicast/UnicastBus.cs @@ -513,7 +513,7 @@ void IBus.Return(T errorCode) MessageSender.Send(returnMessage, _messageBeingHandled.ReplyToAddress); } - void IBus.HandleCurrentMessageLater() + public void HandleCurrentMessageLater() { if (_handleCurrentMessageLaterWasCalled) return; @@ -644,6 +644,11 @@ public ICallback Defer(DateTime processAt, params object[] messages) } } + internal bool HandleCurrentMessageLaterCalled + { + get { return _handleCurrentMessageLaterWasCalled; } + } + private ICallback SendMessage(string destination, string correlationId, MessageIntentEnum messageIntent, params object[] messages) { if (destination == null) From 929abbeca2ab8c569b208873f3d080f78054305a Mon Sep 17 00:00:00 2001 From: John Simons Date: Mon, 7 Jan 2013 14:40:21 +1100 Subject: [PATCH 2/7] SendLocal on workers was causing workers to send extra ready messages, closes #806 Conflicts: src/NServiceBus.Core/ConfigureDistributor.cs src/NServiceBus.Core/ConfigureMasterNode.cs src/NServiceBus.Core/Distributor/Config/WorkerInitializer.cs src/NServiceBus.Core/Unicast/UnicastBus.cs --- default.ps1 | 2 +- .../Config/ConfigureDistributor.cs | 5 +- .../Config/WorkerInitializer.cs | 13 +--- ...NServiceBus.Persistence.Raven.Tests.csproj | 7 +- .../NServiceBus.Persistence.Raven.csproj | 6 +- .../NServiceBus.MasterNode.csproj | 61 ------------------ .../Properties/AssemblyInfo.cs | Bin 1478 -> 0 bytes src/masterNode/masterNode.sln | 20 ------ .../ConfigureMasterNode.cs | 10 +++ .../MasterNodeConfig.cs | 0 .../NServiceBus.Unicast.Config.csproj | 2 + src/unicast/NServiceBus.Unicast/UnicastBus.cs | 18 +++++- 12 files changed, 40 insertions(+), 104 deletions(-) delete mode 100644 src/masterNode/NServiceBus.MasterNode/NServiceBus.MasterNode.csproj delete mode 100644 src/masterNode/NServiceBus.MasterNode/Properties/AssemblyInfo.cs delete mode 100644 src/masterNode/masterNode.sln rename src/{masterNode/NServiceBus.MasterNode => unicast/NServiceBus.Unicast.Config}/ConfigureMasterNode.cs (76%) rename src/{masterNode/NServiceBus.MasterNode => unicast/NServiceBus.Unicast.Config}/MasterNodeConfig.cs (100%) diff --git a/default.ps1 b/default.ps1 index 2b4cd488eec..1097f7536bb 100644 --- a/default.ps1 +++ b/default.ps1 @@ -145,7 +145,7 @@ task TestMain -depends CompileMain -description "Builds NServiceBus.dll, keeps t task CompileCore -depends InitEnvironment -description "Builds NServiceBus.Core.dll and keeps the output in \binaries" { -$coreDirs = "unicastTransport", "ObjectBuilder", "config", "faults", "utils","setup","powershell", "messageInterfaces", "impl\messageInterfaces", "config", "logging", "Impl\ObjectBuilder.Common", "installation", "messagemutator", "encryption", "unitofwork", "masterNode", "impl\installation", "impl\unicast\NServiceBus.Unicast.Msmq", "impl\Serializers","forms", "impl\licensing", "unicast", "headers", "impersonation", "impl\unicast\transport", "impl\unicast\queuing", "impl\unicast\NServiceBus.Unicast.Subscriptions.Msmq", "impl\unicast\NServiceBus.Unicast.Subscriptions.InMemory", "impl\faults", "impl\encryption", "databus", "impl\Sagas", "impl\SagaPersisters\InMemory", "impl\SagaPersisters\RavenSagaPersister", "impl\unicast\NServiceBus.Unicast.Subscriptions.Raven", "integration", "impl\databus", "distributor", "gateway", "scheduling", "satellites", "management\retries", "timeout" +$coreDirs = "unicastTransport", "ObjectBuilder", "config", "faults", "utils","setup","powershell", "messageInterfaces", "impl\messageInterfaces", "config", "logging", "Impl\ObjectBuilder.Common", "installation", "messagemutator", "encryption", "unitofwork", "impl\installation", "impl\unicast\NServiceBus.Unicast.Msmq", "impl\Serializers","forms", "impl\licensing", "unicast", "headers", "impersonation", "impl\unicast\transport", "impl\unicast\queuing", "impl\unicast\NServiceBus.Unicast.Subscriptions.Msmq", "impl\unicast\NServiceBus.Unicast.Subscriptions.InMemory", "impl\faults", "impl\encryption", "databus", "impl\Sagas", "impl\SagaPersisters\InMemory", "impl\SagaPersisters\RavenSagaPersister", "impl\unicast\NServiceBus.Unicast.Subscriptions.Raven", "integration", "impl\databus", "distributor", "gateway", "scheduling", "satellites", "management\retries", "timeout" $coreDirs | % { $solutionDir = Resolve-Path "$srcDir\$_" cd $solutionDir diff --git a/src/distributor/NServiceBus.Distributor/Config/ConfigureDistributor.cs b/src/distributor/NServiceBus.Distributor/Config/ConfigureDistributor.cs index e633dbdda56..3cc7f7c1135 100644 --- a/src/distributor/NServiceBus.Distributor/Config/ConfigureDistributor.cs +++ b/src/distributor/NServiceBus.Distributor/Config/ConfigureDistributor.cs @@ -8,6 +8,7 @@ namespace NServiceBus { using System; using Distributor.Config; + using Unicast; public static class ConfigureDistributor { @@ -44,7 +45,7 @@ public static Configure RunDistributor(this Configure config, bool withWorker = if (withWorker) { - workerRunsOnThisEndpoint = true; + UnicastBus.WorkerRunsOnThisEndpoint = workerRunsOnThisEndpoint = true; WorkerInitializer.Init(); } @@ -70,7 +71,7 @@ public static Configure RunDistributorWithNoWorkerOnItsEndpoint(this Configure c /// public static Configure EnlistWithDistributor(this Configure config) { - workerRunsOnThisEndpoint = true; + UnicastBus.WorkerRunsOnThisEndpoint = workerRunsOnThisEndpoint = true; ValidateMasterNodeConfigurationForWorker(config); diff --git a/src/distributor/NServiceBus.Distributor/Config/WorkerInitializer.cs b/src/distributor/NServiceBus.Distributor/Config/WorkerInitializer.cs index 9bd49b47774..8be824bdb25 100644 --- a/src/distributor/NServiceBus.Distributor/Config/WorkerInitializer.cs +++ b/src/distributor/NServiceBus.Distributor/Config/WorkerInitializer.cs @@ -15,25 +15,16 @@ public static void Init() var unicastBusConfig = Configure.GetConfigSection(); - //allow users to override controll address in config + //allow users to override control address in config if (unicastBusConfig != null && !string.IsNullOrWhiteSpace(unicastBusConfig.DistributorControlAddress)) distributorControlAddress = Address.Parse(unicastBusConfig.DistributorControlAddress); config.Configurer.ConfigureComponent(DependencyLifecycle.SingleInstance) .ConfigureProperty(p => p.DistributorControlAddress, distributorControlAddress); - - var distributorDataAddress = masterNodeAddress; - - //allow users to override data address in config - if (unicastBusConfig != null && !string.IsNullOrWhiteSpace(unicastBusConfig.DistributorDataAddress)) - distributorDataAddress = Address.Parse(unicastBusConfig.DistributorDataAddress); - - - config.Configurer.ConfigureComponent( DependencyLifecycle.SingleInstance) - .ConfigureProperty(r => r.DistributorDataAddress, distributorDataAddress); + .ConfigureProperty(r => r.DistributorDataAddress, masterNodeAddress); } } } \ No newline at end of file diff --git a/src/impl/Persistence/RavenPersistence/NServiceBus.Persistence.Raven.Tests/NServiceBus.Persistence.Raven.Tests.csproj b/src/impl/Persistence/RavenPersistence/NServiceBus.Persistence.Raven.Tests/NServiceBus.Persistence.Raven.Tests.csproj index 2b59fea5796..fc7c7944346 100644 --- a/src/impl/Persistence/RavenPersistence/NServiceBus.Persistence.Raven.Tests/NServiceBus.Persistence.Raven.Tests.csproj +++ b/src/impl/Persistence/RavenPersistence/NServiceBus.Persistence.Raven.Tests/NServiceBus.Persistence.Raven.Tests.csproj @@ -65,16 +65,15 @@ ..\..\..\..\..\build\nservicebus.core\NServiceBus.Installation.dll - - False - ..\..\..\..\..\build\nservicebus.core\NServiceBus.MasterNode.dll - ..\..\..\..\..\build\nservicebus.core\NServiceBus.ObjectBuilder.dll ..\..\..\..\..\build\nservicebus.core\NServiceBus.ObjectBuilder.DefaultBuilder.dll + + ..\..\..\..\..\build\nservicebus.core\NServiceBus.Unicast.Config.dll + ..\..\..\..\..\build\nservicebus.core\NServiceBus.UnitOfWork.dll diff --git a/src/impl/Persistence/RavenPersistence/NServiceBus.Persistence.Raven/NServiceBus.Persistence.Raven.csproj b/src/impl/Persistence/RavenPersistence/NServiceBus.Persistence.Raven/NServiceBus.Persistence.Raven.csproj index e63fd5895f2..621e821bd4c 100644 --- a/src/impl/Persistence/RavenPersistence/NServiceBus.Persistence.Raven/NServiceBus.Persistence.Raven.csproj +++ b/src/impl/Persistence/RavenPersistence/NServiceBus.Persistence.Raven/NServiceBus.Persistence.Raven.csproj @@ -50,15 +50,15 @@ ..\..\..\..\..\build\nservicebus.core\NServiceBus.Installation.Windows.dll - - ..\..\..\..\..\build\nservicebus.core\NServiceBus.MasterNode.dll - ..\..\..\..\..\build\nservicebus.core\NServiceBus.ObjectBuilder.dll ..\..\..\..\..\build\nservicebus.core\NServiceBus.Setup.Windows.dll + + ..\..\..\..\..\build\nservicebus.core\NServiceBus.Unicast.Config.dll + ..\..\..\..\..\build\nservicebus.core\NServiceBus.UnitOfWork.dll diff --git a/src/masterNode/NServiceBus.MasterNode/NServiceBus.MasterNode.csproj b/src/masterNode/NServiceBus.MasterNode/NServiceBus.MasterNode.csproj deleted file mode 100644 index e6afb3e8675..00000000000 --- a/src/masterNode/NServiceBus.MasterNode/NServiceBus.MasterNode.csproj +++ /dev/null @@ -1,61 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {C2AD5F30-0A7D-4146-A9D7-4136B886961B} - Library - Properties - NServiceBus.MasterNode - NServiceBus.MasterNode - v4.0 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\..\..\build\output\NServiceBus.dll - False - - - ..\..\..\build\nservicebus.core\NServiceBus.Config.dll - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/masterNode/NServiceBus.MasterNode/Properties/AssemblyInfo.cs b/src/masterNode/NServiceBus.MasterNode/Properties/AssemblyInfo.cs deleted file mode 100644 index bfb7f5520a0a0e4c64ae3baa728047ae958eeb3b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1478 zcmbVMO-sW-6r8Jq{~`2L4=uGG1U+e`AZQVlUW$j9CNhffF=JuW`uYnMte@dC`Cui>*L1k ze5A}ySY4}ke)YJ@TG15mkzvY=oXl;jk61Ng-O!vOZKy95W^lBzFJ9t+{O9yubOB$!dn2^JqYiC1?fDx4f4#v!iHxzbRy*h0N$9Oh9`Ww4z zR>_DYwUTwm#Pquho0S7H6T@hWZ@lIkG%|DOiz@eb4Q!cDjaG80JSN7c^v+=Yv&9<| zNnL8j9U5#~T=^-XH>B_auhdvvf4+6_u~O%^{a*WH$de6lh90y!;bY6=o($xw!uY1y zi?+D+ytwQ_xyR%G!Hww|sitXmx7?YsQ|gu`(6`n?-mcszAJ_Mkrf6UHdz|vZxMa>A zw4JBYWy*MYRQH2!0L{|UaMqk2@M*qDM!2OLYJD}~(m3Z0lk<_E#7B2V*X#?f>ggBi E7lNDxj{pDw diff --git a/src/masterNode/masterNode.sln b/src/masterNode/masterNode.sln deleted file mode 100644 index 374b4b88662..00000000000 --- a/src/masterNode/masterNode.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.MasterNode", "NServiceBus.MasterNode\NServiceBus.MasterNode.csproj", "{C2AD5F30-0A7D-4146-A9D7-4136B886961B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C2AD5F30-0A7D-4146-A9D7-4136B886961B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C2AD5F30-0A7D-4146-A9D7-4136B886961B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C2AD5F30-0A7D-4146-A9D7-4136B886961B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C2AD5F30-0A7D-4146-A9D7-4136B886961B}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/masterNode/NServiceBus.MasterNode/ConfigureMasterNode.cs b/src/unicast/NServiceBus.Unicast.Config/ConfigureMasterNode.cs similarity index 76% rename from src/masterNode/NServiceBus.MasterNode/ConfigureMasterNode.cs rename to src/unicast/NServiceBus.Unicast.Config/ConfigureMasterNode.cs index 38422888d2b..90100158855 100644 --- a/src/masterNode/NServiceBus.MasterNode/ConfigureMasterNode.cs +++ b/src/unicast/NServiceBus.Unicast.Config/ConfigureMasterNode.cs @@ -29,10 +29,20 @@ public static string GetMasterNode(this Configure config) public static Address GetMasterNodeAddress(this Configure config) { + var unicastBusConfig = Configure.GetConfigSection(); + + //allow users to override data address in config + if (unicastBusConfig != null && !string.IsNullOrWhiteSpace(unicastBusConfig.DistributorDataAddress)) + { + return Address.Parse(unicastBusConfig.DistributorDataAddress); + } + var masterNode = GetMasterNode(config); if (string.IsNullOrWhiteSpace(masterNode)) + { return Address.Parse(Configure.EndpointName); + } ValidateHostName(masterNode); diff --git a/src/masterNode/NServiceBus.MasterNode/MasterNodeConfig.cs b/src/unicast/NServiceBus.Unicast.Config/MasterNodeConfig.cs similarity index 100% rename from src/masterNode/NServiceBus.MasterNode/MasterNodeConfig.cs rename to src/unicast/NServiceBus.Unicast.Config/MasterNodeConfig.cs diff --git a/src/unicast/NServiceBus.Unicast.Config/NServiceBus.Unicast.Config.csproj b/src/unicast/NServiceBus.Unicast.Config/NServiceBus.Unicast.Config.csproj index 72fb33d23c0..6b0e5b058c7 100644 --- a/src/unicast/NServiceBus.Unicast.Config/NServiceBus.Unicast.Config.csproj +++ b/src/unicast/NServiceBus.Unicast.Config/NServiceBus.Unicast.Config.csproj @@ -101,7 +101,9 @@ + + diff --git a/src/unicast/NServiceBus.Unicast/UnicastBus.cs b/src/unicast/NServiceBus.Unicast/UnicastBus.cs index d8e5362ae61..f1fc73b8bb2 100644 --- a/src/unicast/NServiceBus.Unicast/UnicastBus.cs +++ b/src/unicast/NServiceBus.Unicast/UnicastBus.cs @@ -540,8 +540,19 @@ ICallback IBus.SendLocal(Action messageConstructor) return ((IBus)this).SendLocal(CreateInstance(messageConstructor)); } + /// + /// To be used internally by NServiceBus infrastructure. + /// + public static bool WorkerRunsOnThisEndpoint; + ICallback IBus.SendLocal(params object[] messages) { + //if we're a worker, send to the distributor data bus + if (WorkerRunsOnThisEndpoint) + { + return ((IBus)this).Send(MasterNodeAddress, messages); + } + return ((IBus)this).Send(Address.Local, messages); } @@ -644,7 +655,10 @@ public ICallback Defer(DateTime processAt, params object[] messages) } } - internal bool HandleCurrentMessageLaterCalled + /// + /// To be used internally by NServiceBus infrastructure. + /// + public bool HandleCurrentMessageLaterCalled { get { return _handleCurrentMessageLaterWasCalled; } } @@ -951,7 +965,7 @@ IDictionary IBus.OutgoingHeaders } } - IMessageContext IBus.CurrentMessageContext + public IMessageContext CurrentMessageContext { get { From 77cf5cfb68ed35540a523051b1b36ca25d7ea1e0 Mon Sep 17 00:00:00 2001 From: John Simons Date: Mon, 7 Jan 2013 17:14:36 +1100 Subject: [PATCH 3/7] HandleCurrentMessageLater needs to send message back to distributor if endpoint is a worker, closes #851 Conflicts: src/NServiceBus.Core/Distributor/ReadyMessages/ReadyMessageSender.cs src/NServiceBus.Core/Unicast/UnicastBus.cs --- .../ReadyMessages/ReadyMessageSender.cs | 7 +------ src/unicast/NServiceBus.Unicast/UnicastBus.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/distributor/NServiceBus.Distributor/ReadyMessages/ReadyMessageSender.cs b/src/distributor/NServiceBus.Distributor/ReadyMessages/ReadyMessageSender.cs index 31b270fd9f0..70bf89195b8 100644 --- a/src/distributor/NServiceBus.Distributor/ReadyMessages/ReadyMessageSender.cs +++ b/src/distributor/NServiceBus.Distributor/ReadyMessages/ReadyMessageSender.cs @@ -29,12 +29,7 @@ public void Run() { return; } - - if (Bus.HandleCurrentMessageLaterCalled) - { - return; - } - + SendReadyMessage(1); }; } diff --git a/src/unicast/NServiceBus.Unicast/UnicastBus.cs b/src/unicast/NServiceBus.Unicast/UnicastBus.cs index f1fc73b8bb2..fe4943a0555 100644 --- a/src/unicast/NServiceBus.Unicast/UnicastBus.cs +++ b/src/unicast/NServiceBus.Unicast/UnicastBus.cs @@ -516,9 +516,18 @@ void IBus.Return(T errorCode) public void HandleCurrentMessageLater() { if (_handleCurrentMessageLaterWasCalled) + { return; + } - MessageSender.Send(_messageBeingHandled, Address.Local); + if (WorkerRunsOnThisEndpoint) + { + MessageSender.Send(_messageBeingHandled, MasterNodeAddress); + } + else + { + MessageSender.Send(_messageBeingHandled, Address.Local); + } _handleCurrentMessageLaterWasCalled = true; } From 8a1ca3655aa818cf2e5f3b85c12a73d7aaf2852d Mon Sep 17 00:00:00 2001 From: John Simons Date: Thu, 10 Jan 2013 10:22:00 +1100 Subject: [PATCH 4/7] Removed LegacyEndpointRouter has it was not being used, this fixes #878 --- ...n_receiving_a_message_from_another_site.cs | 14 ++-- .../Config/ConfigureGateway.cs | 1 - .../NServiceBus.Gateway.csproj | 1 - .../Routing/Endpoints/LegacyEndpointRouter.cs | 39 ---------- .../Routing/Sites/LegacySiteRouter.cs | 75 ++++++++++--------- 5 files changed, 45 insertions(+), 85 deletions(-) delete mode 100644 src/gateway/NServiceBus.Gateway/Routing/Endpoints/LegacyEndpointRouter.cs diff --git a/src/gateway/NServiceBus.Gateway.Tests/HeaderManagement/When_receiving_a_message_from_another_site.cs b/src/gateway/NServiceBus.Gateway.Tests/HeaderManagement/When_receiving_a_message_from_another_site.cs index d705c8a0ba2..ac3228d4af3 100644 --- a/src/gateway/NServiceBus.Gateway.Tests/HeaderManagement/When_receiving_a_message_from_another_site.cs +++ b/src/gateway/NServiceBus.Gateway.Tests/HeaderManagement/When_receiving_a_message_from_another_site.cs @@ -1,11 +1,8 @@ namespace NServiceBus.Gateway.Tests.HeaderManagement -{ - using System; - using System.Collections.Generic; - using MessageHeaders; +{ + using System.Collections.Generic; using NUnit.Framework; - using Gateway.HeaderManagement; - using Rhino.Mocks; + using Gateway.HeaderManagement; using Unicast.Transport; [TestFixture] @@ -31,7 +28,8 @@ public void SetUp() ReplyToAddress = addressOfOriginatingEndpoint }; - incomingMessage.Headers[Headers.OriginatingSite]=originatingSite; + incomingMessage.Headers[Headers.OriginatingSite] = originatingSite; + incomingMessage.Headers[Headers.HttpFrom] = originatingSite; gatewayHeaderManager = new GatewayHeaderManager(); @@ -50,7 +48,7 @@ public void Should_use_the_originating_sitekey_as_destination_for_response_messa { gatewayHeaderManager.MutateOutgoing(null, responseMessage); - Assert.AreEqual(responseMessage.Headers[Headers.DestinationSites],originatingSite); + Assert.AreEqual(responseMessage.Headers[Headers.HttpTo], originatingSite); } [Test] diff --git a/src/gateway/NServiceBus.Gateway/Config/ConfigureGateway.cs b/src/gateway/NServiceBus.Gateway/Config/ConfigureGateway.cs index 7ecc6007042..9cc50144b6e 100644 --- a/src/gateway/NServiceBus.Gateway/Config/ConfigureGateway.cs +++ b/src/gateway/NServiceBus.Gateway/Config/ConfigureGateway.cs @@ -133,7 +133,6 @@ static void ConfigureSiteRouters(Configure config) static void ConfigureReceiver(Configure config) { config.Configurer.ConfigureComponent(DependencyLifecycle.SingleInstance); - config.Configurer.ConfigureComponent(DependencyLifecycle.SingleInstance); config.Configurer.ConfigureComponent(DependencyLifecycle.SingleInstance); config.Configurer.ConfigureComponent(DependencyLifecycle.InstancePerCall); diff --git a/src/gateway/NServiceBus.Gateway/NServiceBus.Gateway.csproj b/src/gateway/NServiceBus.Gateway/NServiceBus.Gateway.csproj index c8a680c27dc..d88a586dd2a 100644 --- a/src/gateway/NServiceBus.Gateway/NServiceBus.Gateway.csproj +++ b/src/gateway/NServiceBus.Gateway/NServiceBus.Gateway.csproj @@ -146,7 +146,6 @@ - diff --git a/src/gateway/NServiceBus.Gateway/Routing/Endpoints/LegacyEndpointRouter.cs b/src/gateway/NServiceBus.Gateway/Routing/Endpoints/LegacyEndpointRouter.cs deleted file mode 100644 index 24d45bacea3..00000000000 --- a/src/gateway/NServiceBus.Gateway/Routing/Endpoints/LegacyEndpointRouter.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace NServiceBus.Gateway.Routing.Endpoints -{ - using System.Configuration; - using HeaderManagement; - using Unicast.Transport; - - public class LegacyEndpointRouter : IRouteMessagesToEndpoints - { - public Address GetDestinationFor(TransportMessage messageToSend) - { - var routeTo = Headers.RouteTo.Replace(HeaderMapper.NServiceBus + Headers.HeaderName + ".", ""); - - if (messageToSend.Headers.ContainsKey(routeTo)) - return Address.Parse(messageToSend.Headers[routeTo]); - - return DefaultDestinationAddress; - } - - Address DefaultDestinationAddress - { - get - { - if(defaultDestinationAddress == null) - { - var outputQueue = ConfigurationManager.AppSettings["OutputQueue"]; - - if (string.IsNullOrEmpty(outputQueue)) - throw new ConfigurationErrorsException("Required setting 'OutputQueue' is missing"); - - defaultDestinationAddress = Address.Parse(outputQueue); - } - return defaultDestinationAddress; - } - } - - Address defaultDestinationAddress; - - } -} \ No newline at end of file diff --git a/src/gateway/NServiceBus.Gateway/Routing/Sites/LegacySiteRouter.cs b/src/gateway/NServiceBus.Gateway/Routing/Sites/LegacySiteRouter.cs index 737e9826913..b2b7e16c87e 100644 --- a/src/gateway/NServiceBus.Gateway/Routing/Sites/LegacySiteRouter.cs +++ b/src/gateway/NServiceBus.Gateway/Routing/Sites/LegacySiteRouter.cs @@ -1,37 +1,40 @@ -namespace NServiceBus.Gateway.Routing.Sites -{ - using System.Collections.Generic; - using System.Configuration; - using Channels; - using Unicast.Transport; - - public class LegacySiteRouter:IRouteMessagesToSites - { - readonly string remoteUrl; - - public LegacySiteRouter() - { - remoteUrl = ConfigurationManager.AppSettings["RemoteUrl"]; - } - - public IEnumerable GetDestinationSitesFor(TransportMessage messageToDispatch) - { - var address = GetRemoteAddress(messageToDispatch); - - return new []{new Site - { - Channel = new Channel{Address = address,Type = "Http"}, - Key = address - }}; - } - - string GetRemoteAddress(TransportMessage msg) - { - if (msg.Headers.ContainsKey(Headers.HttpTo)) - return msg.Headers[Headers.HttpTo]; - - return remoteUrl; - } - - } +namespace NServiceBus.Gateway.Routing.Sites +{ + using System.Collections.Generic; + using System.Configuration; + using Channels; + using Unicast.Transport; + + public class LegacySiteRouter : IRouteMessagesToSites + { + private readonly string remoteUrl; + + public LegacySiteRouter() + { + remoteUrl = ConfigurationManager.AppSettings["RemoteUrl"]; + } + + public IEnumerable GetDestinationSitesFor(TransportMessage messageToDispatch) + { + var address = GetRemoteAddress(messageToDispatch); + + return new[] + { + new Site + { + Channel = new Channel {Address = address, Type = "Http"}, + Key = address + } + }; + } + + private string GetRemoteAddress(TransportMessage msg) + { + if (msg.Headers.ContainsKey(Headers.HttpTo)) + return msg.Headers[Headers.HttpTo]; + + return remoteUrl; + } + + } } \ No newline at end of file From d139e161d22ef783d345d68fc54c5391487ebbca Mon Sep 17 00:00:00 2001 From: John Simons Date: Mon, 14 Jan 2013 10:10:48 +1100 Subject: [PATCH 5/7] Invalid types were being mapped to addresses, closes #866 Conflicts: src/NServiceBus.Core/Unicast/Config/ConfigUnicastBus.cs --- .../ConfigUnicastBus.cs | 5 + .../ANamespace/ASubNamespace/MessageD.cs | 4 +- .../ANamespace/MessageC.cs | 4 +- .../MessageA.cs | 12 +- .../MessageB.cs | 4 +- .../NServiceBus.Unicast.Tests.Messages.csproj | 103 +++++++++--------- .../ConfiguringMessageEndpointMapping.cs | 12 +- .../NServiceBus.Unicast.Tests.csproj | 5 +- 8 files changed, 74 insertions(+), 75 deletions(-) diff --git a/src/unicast/NServiceBus.Unicast.Config/ConfigUnicastBus.cs b/src/unicast/NServiceBus.Unicast.Config/ConfigUnicastBus.cs index ac07b1be59a..22aef17d6ab 100644 --- a/src/unicast/NServiceBus.Unicast.Config/ConfigUnicastBus.cs +++ b/src/unicast/NServiceBus.Unicast.Config/ConfigUnicastBus.cs @@ -85,6 +85,11 @@ void RegisterMessageOwnersAndBusAddress() private void MapTypeToAddress(Type messagesType, Address address) { + if (!messagesType.IsMessageType()) + { + return; + } + if (typesToEndpoints.ContainsKey(messagesType) && typesToEndpoints[messagesType] != Address.Undefined) { return; diff --git a/src/unicast/NServiceBus.Unicast.Tests.Messages/ANamespace/ASubNamespace/MessageD.cs b/src/unicast/NServiceBus.Unicast.Tests.Messages/ANamespace/ASubNamespace/MessageD.cs index 3d577f48b58..938928a5b83 100644 --- a/src/unicast/NServiceBus.Unicast.Tests.Messages/ANamespace/ASubNamespace/MessageD.cs +++ b/src/unicast/NServiceBus.Unicast.Tests.Messages/ANamespace/ASubNamespace/MessageD.cs @@ -1,6 +1,6 @@ namespace NServiceBus.Unicast.Tests.Messages.ANamespace.ASubNamespace -{ - public class MessageD +{ + public class MessageD : IMessage { } diff --git a/src/unicast/NServiceBus.Unicast.Tests.Messages/ANamespace/MessageC.cs b/src/unicast/NServiceBus.Unicast.Tests.Messages/ANamespace/MessageC.cs index 2ac11c61e3f..83bb9580d1b 100644 --- a/src/unicast/NServiceBus.Unicast.Tests.Messages/ANamespace/MessageC.cs +++ b/src/unicast/NServiceBus.Unicast.Tests.Messages/ANamespace/MessageC.cs @@ -1,6 +1,6 @@ namespace NServiceBus.Unicast.Tests.Messages.ANamespace -{ - public class MessageC +{ + public class MessageC : IMessage { } diff --git a/src/unicast/NServiceBus.Unicast.Tests.Messages/MessageA.cs b/src/unicast/NServiceBus.Unicast.Tests.Messages/MessageA.cs index 5d7029f97b0..72724e607ec 100644 --- a/src/unicast/NServiceBus.Unicast.Tests.Messages/MessageA.cs +++ b/src/unicast/NServiceBus.Unicast.Tests.Messages/MessageA.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NServiceBus.Unicast.Tests.Messages -{ - public class MessageA +namespace NServiceBus.Unicast.Tests.Messages +{ + public class MessageA : IMessage { } } diff --git a/src/unicast/NServiceBus.Unicast.Tests.Messages/MessageB.cs b/src/unicast/NServiceBus.Unicast.Tests.Messages/MessageB.cs index 50cafcaf37a..311049e84d9 100644 --- a/src/unicast/NServiceBus.Unicast.Tests.Messages/MessageB.cs +++ b/src/unicast/NServiceBus.Unicast.Tests.Messages/MessageB.cs @@ -1,6 +1,6 @@ namespace NServiceBus.Unicast.Tests.Messages -{ - public class MessageB +{ + public class MessageB : IMessage { } diff --git a/src/unicast/NServiceBus.Unicast.Tests.Messages/NServiceBus.Unicast.Tests.Messages.csproj b/src/unicast/NServiceBus.Unicast.Tests.Messages/NServiceBus.Unicast.Tests.Messages.csproj index 46ee8b50840..9bc0c7342f7 100644 --- a/src/unicast/NServiceBus.Unicast.Tests.Messages/NServiceBus.Unicast.Tests.Messages.csproj +++ b/src/unicast/NServiceBus.Unicast.Tests.Messages/NServiceBus.Unicast.Tests.Messages.csproj @@ -1,57 +1,60 @@ - - - - - Debug - AnyCPU - {50C0CD53-6C74-4554-8D8A-A529943A7409} - Library - Properties - NServiceBus.Unicast.Tests.Messages - NServiceBus.Unicast.Tests.Messages - v4.0 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - + + + + + Debug + AnyCPU + {50C0CD53-6C74-4554-8D8A-A529943A7409} + Library + Properties + NServiceBus.Unicast.Tests.Messages + NServiceBus.Unicast.Tests.Messages + v4.0 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\build\output\NServiceBus.dll + + + + + + + + + + + + + + + + + + --> \ No newline at end of file diff --git a/src/unicast/NServiceBus.Unicast.Tests/ConfiguringMessageEndpointMapping.cs b/src/unicast/NServiceBus.Unicast.Tests/ConfiguringMessageEndpointMapping.cs index be8fc9f40a4..7944ad95a0b 100644 --- a/src/unicast/NServiceBus.Unicast.Tests/ConfiguringMessageEndpointMapping.cs +++ b/src/unicast/NServiceBus.Unicast.Tests/ConfiguringMessageEndpointMapping.cs @@ -8,12 +8,12 @@ using NUnit.Framework; namespace NServiceBus.Unicast.Tests.Messages -{ - public class MessageE - { - } - - public class MessageF +{ + public class MessageE : IMessage + { + } + + public class MessageF : IMessage { } } diff --git a/src/unicast/NServiceBus.Unicast.Tests/NServiceBus.Unicast.Tests.csproj b/src/unicast/NServiceBus.Unicast.Tests/NServiceBus.Unicast.Tests.csproj index c3c58d0c4cd..98097eda9a6 100644 --- a/src/unicast/NServiceBus.Unicast.Tests/NServiceBus.Unicast.Tests.csproj +++ b/src/unicast/NServiceBus.Unicast.Tests/NServiceBus.Unicast.Tests.csproj @@ -49,9 +49,6 @@ ..\..\..\build\nservicebus.core\NServiceBus.Licensing.dll - - ..\..\..\build\nservicebus.core\NServiceBus.MasterNode.dll - ..\..\..\build\nservicebus.core\NServiceBus.MessageInterfaces.dll @@ -152,4 +149,4 @@ --> - + \ No newline at end of file From 5b06eabe41840f6c11cd01686f433e7e37f54818 Mon Sep 17 00:00:00 2001 From: John Simons Date: Mon, 14 Jan 2013 10:12:24 +1100 Subject: [PATCH 6/7] Ensuring a product update is done correctly. --- src/wix/WixInstaller/Product.wxs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wix/WixInstaller/Product.wxs b/src/wix/WixInstaller/Product.wxs index 9b963c99ac9..8c5852d2278 100644 --- a/src/wix/WixInstaller/Product.wxs +++ b/src/wix/WixInstaller/Product.wxs @@ -1,6 +1,6 @@ - + Date: Mon, 14 Jan 2013 16:10:41 +1100 Subject: [PATCH 7/7] Enable WCF hosting in unobtrusive mode, fixes #889 Conflicts: src/NServiceBus.Core/Hosting/GenericHost.cs src/NServiceBus.Core/Hosting/Wcf/WcfManager.cs --- .../NServiceBus.Hosting/GenericHost.cs | 2 +- .../NServiceBus.Hosting/Wcf/WcfManager.cs | 38 +++++++------------ 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/hosting/NServiceBus.Hosting/GenericHost.cs b/src/hosting/NServiceBus.Hosting/GenericHost.cs index 689fd3fc38a..585f41aaded 100644 --- a/src/hosting/NServiceBus.Hosting/GenericHost.cs +++ b/src/hosting/NServiceBus.Hosting/GenericHost.cs @@ -148,7 +148,7 @@ public GenericHost(IConfigureThisEndpoint specifier, string[] args, IEnumerable< ProfileActivator.ProfileManager = profileManager; configManager = new ConfigManager(assembliesToScan, specifier); - wcfManager = new WcfManager(assembliesToScan); + wcfManager = new WcfManager(); roleManager = new RoleManager(assembliesToScan); } diff --git a/src/hosting/NServiceBus.Hosting/Wcf/WcfManager.cs b/src/hosting/NServiceBus.Hosting/Wcf/WcfManager.cs index e6e4aec3f5b..fd7fb1ba5fb 100644 --- a/src/hosting/NServiceBus.Hosting/Wcf/WcfManager.cs +++ b/src/hosting/NServiceBus.Hosting/Wcf/WcfManager.cs @@ -1,39 +1,27 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.ServiceModel; -using System.ServiceModel.Channels; -using log4net; - -namespace NServiceBus.Hosting.Wcf -{ +namespace NServiceBus.Hosting.Wcf +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.ServiceModel; + using System.ServiceModel.Channels; + using log4net; + /// /// Enable users to expose messages as WCF services /// public class WcfManager { - private readonly List serviceTypes = new List(); private readonly List hosts = new List(); - - /// - /// Initlalized the manager with the list of assemblies to be scanned - /// - /// - public WcfManager(IEnumerable assembliesToScan) - { - foreach (var a in assembliesToScan) - foreach (var t in a.GetTypes()) - if (IsWcfService(t) && !t.IsAbstract) - serviceTypes.Add(t); - } /// /// Starts a servicehost for each found service. Defaults to BasicHttpBinding if /// no user specified binding is found /// public void Startup() - { - foreach (var serviceType in serviceTypes) + { + + foreach (var serviceType in Configure.TypesToScan.Where(t => !t.IsAbstract && IsWcfService(t))) { var host = new WcfServiceHost(serviceType); @@ -72,7 +60,7 @@ private static bool IsWcfService(Type t) { var args = t.GetGenericArguments(); if (args.Length == 2) - if (typeof(IMessage).IsAssignableFrom(args[0])) + if (args[0].IsMessageType()) { var wcfType = typeof(WcfService<,>).MakeGenericType(args); if (wcfType.IsAssignableFrom(t))