Skip to content

Commit

Permalink
Merge branch 'hotfix-4.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasohlund committed Dec 20, 2013
2 parents 792cd5c + 81700c7 commit 5f5680d
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 27 deletions.
12 changes: 9 additions & 3 deletions packaging/nuget/tools/init.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ Write-Host ""
$nserviceBusKeyPath = "HKCU:SOFTWARE\NServiceBus"
$machinePreparedKey = "MachinePrepared"
$machinePrepared = $false
$nservicebusVersion = Get-NServiceBusVersion
$nserviceBusVersionPath = $nserviceBusKeyPath + "\" + $nservicebusVersion.Major + "." + $nservicebusVersion.Minor
$versionParts = $package.Version.Split('.')
$nservicebusVersion = $versionParts[0]

if($versionParts.Length -gt 1) {
$nservicebusVersion += "." + $versionParts[1]
}

$nserviceBusVersionPath = $nserviceBusKeyPath + "\" + $nservicebusVersion

#Figure out if this machine is properly setup
try {
Expand All @@ -28,7 +34,7 @@ try {
}

if (!(Test-Path $nserviceBusVersionPath)){
$versionToAdd = $nservicebusVersion.Major.ToString() + "." + $nservicebusVersion.Minor.ToString()
$versionToAdd = $nservicebusVersion
New-Item -Path $nserviceBusKeyPath -Name $versionToAdd | Out-Null
New-ItemProperty -Path $nserviceBusVersionPath -Name $machinePreparedKey -PropertyType String -Value "false" | Out-Null
}
Expand Down
59 changes: 55 additions & 4 deletions src/NServiceBus.AcceptanceTests/PubSub/When_publishing_an_event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,36 @@

public class When_publishing_an_event : NServiceBusAcceptanceTest
{
[Test]
public void Issue_1851()
{
Scenario.Define<Context>()
.WithEndpoint<Publisher>(b =>
b.Given((bus, context) => Subscriptions.OnEndpointSubscribed(s =>
{
if (s.SubscriberReturnAddress.Queue.Contains("Subscriber3"))
{
context.Subscriber3Subscribed = true;
}
}))
.When(c => c.Subscriber3Subscribed, bus => bus.Publish<IFoo>())
)
.WithEndpoint<Subscriber3>(b => b.Given((bus, context) =>
{
bus.Subscribe<IFoo>();
if (!Feature.IsEnabled<MessageDrivenSubscriptions>())
{
context.Subscriber3Subscribed = true;
}
}))

.Done(c => c.Subscriber3GotTheEvent)
.Repeat(r => r.For(Transports.Msmq))
.Should(c => Assert.True(c.Subscriber3GotTheEvent))
.Run();
}

[Test]
public void Should_be_delivered_to_allsubscribers()
{
Expand Down Expand Up @@ -52,13 +82,11 @@ public void Should_be_delivered_to_allsubscribers()
public class Context : ScenarioContext
{
public bool Subscriber1GotTheEvent { get; set; }

public bool Subscriber2GotTheEvent { get; set; }


public bool Subscriber3GotTheEvent { get; set; }
public bool Subscriber1Subscribed { get; set; }

public bool Subscriber2Subscribed { get; set; }
public bool Subscriber3Subscribed { get; set; }
}

public class Publisher : EndpointConfigurationBuilder
Expand All @@ -69,6 +97,25 @@ public Publisher()
}
}

public class Subscriber3 : EndpointConfigurationBuilder
{
public Subscriber3()
{
EndpointSetup<DefaultServer>(c => Configure.Features.Disable<AutoSubscribe>())
.AddMapping<IFoo>(typeof(Publisher));
}

public class MyEventHandler : IHandleMessages<IFoo>
{
public Context Context { get; set; }

public void Handle(IFoo messageThatIsEnlisted)
{
Context.Subscriber3GotTheEvent = true;
}
}
}

public class Subscriber1 : EndpointConfigurationBuilder
{
public Subscriber1()
Expand Down Expand Up @@ -107,6 +154,10 @@ public void Handle(MyEvent messageThatIsEnlisted)
}
}

public interface IFoo : IEvent
{
}

[Serializable]
public class MyEvent : IEvent
{
Expand Down
93 changes: 84 additions & 9 deletions src/NServiceBus.Core/Licensing/LicenseLocationConventions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static class LicenseLocationConventions

public static void StoreLicenseInRegistry(string license)
{
var keyPath = String.Format(@"SOFTWARE\NServiceBus\{0}", NServiceBusVersion.MajorAndMinor);
var keyPath = @"SOFTWARE\ParticularSoftware\NServiceBus";

try
{
Expand Down Expand Up @@ -71,25 +71,93 @@ public static string TryFindLicenseText()
return NonLockingFileReader.ReadAllTextWithoutLocking(oldLocalLicenseFile);
}

var hkcuLicense = GetHKCULicense();
var registryLicence = LoadLicenseFromRegistry();
if (!String.IsNullOrEmpty(registryLicence))
{
return registryLicence;
}

registryLicence = LoadLicenseFromPreviousRegistryLocation("4.3");
if (!String.IsNullOrEmpty(registryLicence))
{
return registryLicence;
}

registryLicence = LoadLicenseFromPreviousRegistryLocation("4.2");
if (!String.IsNullOrEmpty(registryLicence))
{
return registryLicence;
}

registryLicence = LoadLicenseFromPreviousRegistryLocation("4.1");
if (!String.IsNullOrEmpty(registryLicence))
{
return registryLicence;
}

registryLicence = LoadLicenseFromPreviousRegistryLocation("4.0");
if (!String.IsNullOrEmpty(registryLicence))
{
return registryLicence;
}

return null;
}

static string LoadLicenseFromRegistry()
{
var hkcuLicense = GetHKCULicense(@"ParticularSoftware\NServiceBus");

if (!String.IsNullOrEmpty(hkcuLicense))
{
Logger.Info(@"Using embedded license found in registry [HKEY_CURRENT_USER\Software\ParticularSoftware\NServiceBus\License].");

return hkcuLicense;
}

var hklmLicense = GetHKLMLicense(@"ParticularSoftware\NServiceBus");
if (!String.IsNullOrEmpty(hklmLicense))
{
Logger.Info(@"Using embedded license found in registry [HKEY_LOCAL_MACHINE\Software\ParticularSoftware\NServiceBus\License].");

return hklmLicense;
}

return null;
}

static string LoadLicenseFromPreviousRegistryLocation(string version)
{
var hkcuLicense = GetHKCULicense(subKey: version);

if (!String.IsNullOrEmpty(hkcuLicense))
{
Logger.InfoFormat(@"Using embedded license found in registry [HKEY_CURRENT_USER\Software\NServiceBus\{0}\License].", NServiceBusVersion.MajorAndMinor);
Logger.InfoFormat(@"Using embedded license found in registry [HKEY_CURRENT_USER\Software\NServiceBus\{0}\License].", version);

return hkcuLicense;
}

var hklmLicense = GetHKLMLicense();
var hklmLicense = GetHKLMLicense(subKey: version);
if (!String.IsNullOrEmpty(hklmLicense))
{
Logger.InfoFormat(@"Using embedded license found in registry [HKEY_LOCAL_MACHINE\Software\NServiceBus\{0}\License].", NServiceBusVersion.MajorAndMinor);
Logger.InfoFormat(@"Using embedded license found in registry [HKEY_LOCAL_MACHINE\Software\NServiceBus\{0}\License].", version);

return hklmLicense;
}

return null;
}

public static string GetHKCULicense()
static string GetHKCULicense(string softwareKey = "NServiceBus", string subKey = null)
{
using (var registryKey = Registry.CurrentUser.OpenSubKey(String.Format(@"SOFTWARE\NServiceBus\{0}", NServiceBusVersion.MajorAndMinor)))
var keyPath = @"SOFTWARE\" + softwareKey;

if (subKey != null)
{
keyPath += @"\" + subKey;
}

using (var registryKey = Registry.CurrentUser.OpenSubKey(keyPath))
{
if (registryKey != null)
{
Expand All @@ -99,11 +167,18 @@ public static string GetHKCULicense()
return null;
}

public static string GetHKLMLicense()
static string GetHKLMLicense(string softwareKey = "NServiceBus", string subKey = null)
{
var keyPath = @"SOFTWARE\" + softwareKey;

if (subKey != null)
{
keyPath += @"\" + subKey;
}

try
{
using (var registryKey = Registry.LocalMachine.OpenSubKey(String.Format(@"SOFTWARE\NServiceBus\{0}", NServiceBusVersion.MajorAndMinor)))
using (var registryKey = Registry.LocalMachine.OpenSubKey(keyPath))
{
if (registryKey != null)
{
Expand Down
17 changes: 10 additions & 7 deletions src/NServiceBus.Core/Unicast/UnicastBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace NServiceBus.Unicast
using Routing;
using Satellites;
using Serialization;
using Settings;
using Subscriptions;
using Subscriptions.MessageDrivenSubscriptions.SubcriberSideFiltering;
using Support;
Expand Down Expand Up @@ -281,18 +280,16 @@ public virtual void Publish<T>(T message)
/// </summary>
public virtual void Publish<T>()
{
Publish(new object[] { });
Publish(CreateInstance<T>());
}

/// <summary>
/// Publishes the messages to all subscribers of the first message's type.
/// </summary>
public virtual void Publish<T>(params T[] messages)
{

if (messages == null || messages.Length == 0) // Bus.Publish<IFoo>();
if (messages == null || messages.Length == 0)
{
Publish(CreateInstance<T>(m => { }));
return;
}

Expand Down Expand Up @@ -369,8 +366,8 @@ public virtual void Subscribe(Type messageType, Predicate<object> condition)
throw new InvalidOperationException("No subscription manager is available");
}

if (TransportDefinition.HasSupportForCentralizedPubSub)
{
if (TransportDefinition.HasSupportForCentralizedPubSub && !IsAzureTransport())
{
// We are dealing with a brokered transport wired for auto pub/sub.
SubscriptionManager.Subscribe(messageType, null);
return;
Expand Down Expand Up @@ -398,6 +395,12 @@ public virtual void Subscribe(Type messageType, Predicate<object> condition)
}
}

[ObsoleteEx(RemoveInVersion = "5.0")]
bool IsAzureTransport()
{
return TransportDefinition.GetType().Name.ToLower().Contains("azure");
}

/// <summary>
/// Unsubscribes from the given type of message - T.
/// </summary>
Expand Down
6 changes: 2 additions & 4 deletions src/licenseinstaller/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ static bool TryToWriteToRegistry(string selectedLicenseText, RegistryView view)
rootKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, view);
}

using (
var registryKey =
rootKey.CreateSubKey(String.Format(@"SOFTWARE\NServiceBus\{0}", GetNServiceBusVersion().ToString(2))))
using (var registryKey = rootKey.CreateSubKey(@"SOFTWARE\ParticularSoftware\NServiceBus"))
{
if (registryKey == null)
{
Expand All @@ -87,7 +85,7 @@ static bool TryParseOptions(IEnumerable<string> args)
{
{
"current-user|c",
@"Installs license in HKEY_CURRENT_USER\SOFTWARE\NServiceBus, by default if not specified the license is installed in HKEY_LOCAL_MACHINE\SOFTWARE\NServiceBus"
@"Installs license in HKEY_CURRENT_USER\SOFTWARE\ParticularSoftware\NServiceBus, by default if not specified the license is installed in HKEY_LOCAL_MACHINE\SOFTWARE\ParticularSoftware\NServiceBus"
, s => action = () =>
{
useHKCU = true;
Expand Down

0 comments on commit 5f5680d

Please sign in to comment.