From 46075be1a9ce387af0c1dc75d53545379d8d7a10 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Thu, 5 Dec 2013 11:49:23 +1100 Subject: [PATCH 1/3] dont log "empty message" for control messages --- .../Unicast/Messages/ExecuteLogicalMessagesBehavior.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/NServiceBus.Core/Unicast/Messages/ExecuteLogicalMessagesBehavior.cs b/src/NServiceBus.Core/Unicast/Messages/ExecuteLogicalMessagesBehavior.cs index 52e24858b4..89717fc734 100644 --- a/src/NServiceBus.Core/Unicast/Messages/ExecuteLogicalMessagesBehavior.cs +++ b/src/NServiceBus.Core/Unicast/Messages/ExecuteLogicalMessagesBehavior.cs @@ -6,6 +6,7 @@ using Logging; using Pipeline; using Pipeline.Contexts; + using Transport; class ExecuteLogicalMessagesBehavior : IBehavior { @@ -25,9 +26,13 @@ public void Invoke(ReceivePhysicalMessageContext context, Action next) PipelineFactory.InvokeLogicalMessagePipeline(message); } - if (!logicalMessages.Any()) + + if (!context.PhysicalMessage.IsControlMessage()) { - log.Warn("Received an empty message - ignoring."); + if (!logicalMessages.Any()) + { + log.Warn("Received an empty message - ignoring."); + } } next(); From 413b4f1bae3e255885cc2226dbe320edb904d908 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Thu, 5 Dec 2013 15:59:00 +1100 Subject: [PATCH 2/3] delay loading of license to give fluent API a chance to configure it --- .../Licensing/LicenseManager.cs | 25 +++++++++++++------ .../Licensing/LicenseVerifier.cs | 11 -------- src/NServiceBus.Core/NServiceBus.Core.csproj | 1 - .../LicenseConfig.cs | 8 +----- 4 files changed, 19 insertions(+), 26 deletions(-) delete mode 100644 src/NServiceBus.Core/Licensing/LicenseVerifier.cs diff --git a/src/NServiceBus.Core/Licensing/LicenseManager.cs b/src/NServiceBus.Core/Licensing/LicenseManager.cs index 8e38736358..31f478cd5c 100644 --- a/src/NServiceBus.Core/Licensing/LicenseManager.cs +++ b/src/NServiceBus.Core/Licensing/LicenseManager.cs @@ -32,7 +32,7 @@ internal static void PromptUserForLicenseIfTrialHasExpired() //TODO: should we display dialog if UpgradeProtection is not valid? if (ExpiryChecker.IsExpired(License.ExpirationDate)) { - License = LicenseExpiredFormDisplayer.PromptUserForLicense(); + license = LicenseExpiredFormDisplayer.PromptUserForLicense(); } } } @@ -58,7 +58,7 @@ static void ConfigureNServiceBusToRunInTrialMode() { Logger.WarnFormat("Trial for NServiceBus v{0} has expired. Falling back to run in Basic1 license mode.", NServiceBusVersion.MajorAndMinor); - License = LicenseDeserializer.GetBasicLicense(); + license = LicenseDeserializer.GetBasicLicense(); } else { @@ -66,14 +66,14 @@ static void ConfigureNServiceBusToRunInTrialMode() Logger.Info(message); //Run in unlimited mode during trial period - License = LicenseDeserializer.GetTrialLicense(trialExpirationDate); + license = LicenseDeserializer.GetTrialLicense(trialExpirationDate); } return; } Logger.Warn("Could not access registry for the current user sid. Falling back to run in Basic license mode."); - License = LicenseDeserializer.GetBasicLicense(); + license = LicenseDeserializer.GetBasicLicense(); } internal static void Verify() @@ -96,18 +96,29 @@ internal static void Verify() { message = message + " You can renew it at http://particular.net/licensing. Downgrading to basic mode"; Logger.Warn(message); - License = LicenseDeserializer.GetBasicLicense(); + license = LicenseDeserializer.GetBasicLicense(); } else { - License = tempLicense; + license = tempLicense; } WriteLicenseInfo(); } static ILog Logger = LogManager.GetLogger(typeof(LicenseManager)); - public static License License; + public static License License + { + get + { + if (license == null) + { + Verify(); + } + return license; + } + } static string licenseText; + static License license; } } \ No newline at end of file diff --git a/src/NServiceBus.Core/Licensing/LicenseVerifier.cs b/src/NServiceBus.Core/Licensing/LicenseVerifier.cs deleted file mode 100644 index 1957822fde..0000000000 --- a/src/NServiceBus.Core/Licensing/LicenseVerifier.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace NServiceBus.Licensing -{ - - class LicenseVerifier : IWantToRunBeforeConfiguration - { - public void Init() - { - LicenseManager.Verify(); - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.Core/NServiceBus.Core.csproj b/src/NServiceBus.Core/NServiceBus.Core.csproj index 3e67e85926..bea72dede0 100644 --- a/src/NServiceBus.Core/NServiceBus.Core.csproj +++ b/src/NServiceBus.Core/NServiceBus.Core.csproj @@ -122,7 +122,6 @@ - diff --git a/src/NServiceBus.Distributor.MSMQ/LicenseConfig.cs b/src/NServiceBus.Distributor.MSMQ/LicenseConfig.cs index 73c0ca991d..f4929aeac8 100644 --- a/src/NServiceBus.Distributor.MSMQ/LicenseConfig.cs +++ b/src/NServiceBus.Distributor.MSMQ/LicenseConfig.cs @@ -10,18 +10,13 @@ namespace NServiceBus.Distributor.MSMQ /// internal static class LicenseConfig { - static LicenseConfig() - { - allowedWorkerNodes = LicenseManager.License.AllowedNumberOfWorkerNodes; - } - internal static bool LimitNumberOfWorkers(Address workerAddress) { if (WorkersList.Contains(workerAddress)) { return false; } - + var allowedWorkerNodes = LicenseManager.License.AllowedNumberOfWorkerNodes; if (WorkersList.Count < allowedWorkerNodes) { WorkersList.Add(workerAddress); @@ -34,7 +29,6 @@ internal static bool LimitNumberOfWorkers(Address workerAddress) } static readonly ILog Logger = LogManager.GetLogger(typeof(LicenseConfig)); - static readonly int allowedWorkerNodes; static readonly ConcurrentBag
WorkersList = new ConcurrentBag
(); } } \ No newline at end of file From 83f65dd5b66f602e17f8ad80764c6f54b61e8bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Thu, 5 Dec 2013 08:59:37 +0100 Subject: [PATCH 3/3] Making delete subkey not throw even though that should be the default. Microsoft is lying to us :( --- .../Licensing/TrialLicenseReaderTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NServiceBus.Core.Tests/Licensing/TrialLicenseReaderTests.cs b/src/NServiceBus.Core.Tests/Licensing/TrialLicenseReaderTests.cs index 6adcb44f5d..025590e1b2 100644 --- a/src/NServiceBus.Core.Tests/Licensing/TrialLicenseReaderTests.cs +++ b/src/NServiceBus.Core.Tests/Licensing/TrialLicenseReaderTests.cs @@ -13,7 +13,8 @@ public class TrialLicenseReaderTests public void When_no_sub_key_exists_one_is_created() { var subKeyPath = String.Format(@"SOFTWARE\NServiceBus\{0}", NServiceBusVersion.MajorAndMinor); - Registry.CurrentUser.DeleteSubKey(subKeyPath); + + Registry.CurrentUser.DeleteSubKey(subKeyPath,false); var expirationFromRegistry = TrialLicenseReader.GetTrialExpirationFromRegistry(); Assert.AreEqual(DateTime.UtcNow.AddDays(TrialLicenseReader.TRIAL_DAYS).Date, expirationFromRegistry.Date); Assert.IsNotNull(Registry.CurrentUser.OpenSubKey(subKeyPath));