Skip to content

Commit 5f5680d

Browse files
committed
Merge branch 'hotfix-4.3.2'
2 parents 792cd5c + 81700c7 commit 5f5680d

File tree

5 files changed

+160
-27
lines changed

5 files changed

+160
-27
lines changed

packaging/nuget/tools/init.ps1

+9-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ Write-Host ""
1818
$nserviceBusKeyPath = "HKCU:SOFTWARE\NServiceBus"
1919
$machinePreparedKey = "MachinePrepared"
2020
$machinePrepared = $false
21-
$nservicebusVersion = Get-NServiceBusVersion
22-
$nserviceBusVersionPath = $nserviceBusKeyPath + "\" + $nservicebusVersion.Major + "." + $nservicebusVersion.Minor
21+
$versionParts = $package.Version.Split('.')
22+
$nservicebusVersion = $versionParts[0]
23+
24+
if($versionParts.Length -gt 1) {
25+
$nservicebusVersion += "." + $versionParts[1]
26+
}
27+
28+
$nserviceBusVersionPath = $nserviceBusKeyPath + "\" + $nservicebusVersion
2329

2430
#Figure out if this machine is properly setup
2531
try {
@@ -28,7 +34,7 @@ try {
2834
}
2935

3036
if (!(Test-Path $nserviceBusVersionPath)){
31-
$versionToAdd = $nservicebusVersion.Major.ToString() + "." + $nservicebusVersion.Minor.ToString()
37+
$versionToAdd = $nservicebusVersion
3238
New-Item -Path $nserviceBusKeyPath -Name $versionToAdd | Out-Null
3339
New-ItemProperty -Path $nserviceBusVersionPath -Name $machinePreparedKey -PropertyType String -Value "false" | Out-Null
3440
}

src/NServiceBus.AcceptanceTests/PubSub/When_publishing_an_event.cs

+55-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,36 @@
99

1010
public class When_publishing_an_event : NServiceBusAcceptanceTest
1111
{
12+
[Test]
13+
public void Issue_1851()
14+
{
15+
Scenario.Define<Context>()
16+
.WithEndpoint<Publisher>(b =>
17+
b.Given((bus, context) => Subscriptions.OnEndpointSubscribed(s =>
18+
{
19+
if (s.SubscriberReturnAddress.Queue.Contains("Subscriber3"))
20+
{
21+
context.Subscriber3Subscribed = true;
22+
}
23+
}))
24+
.When(c => c.Subscriber3Subscribed, bus => bus.Publish<IFoo>())
25+
)
26+
.WithEndpoint<Subscriber3>(b => b.Given((bus, context) =>
27+
{
28+
bus.Subscribe<IFoo>();
29+
30+
if (!Feature.IsEnabled<MessageDrivenSubscriptions>())
31+
{
32+
context.Subscriber3Subscribed = true;
33+
}
34+
}))
35+
36+
.Done(c => c.Subscriber3GotTheEvent)
37+
.Repeat(r => r.For(Transports.Msmq))
38+
.Should(c => Assert.True(c.Subscriber3GotTheEvent))
39+
.Run();
40+
}
41+
1242
[Test]
1343
public void Should_be_delivered_to_allsubscribers()
1444
{
@@ -52,13 +82,11 @@ public void Should_be_delivered_to_allsubscribers()
5282
public class Context : ScenarioContext
5383
{
5484
public bool Subscriber1GotTheEvent { get; set; }
55-
5685
public bool Subscriber2GotTheEvent { get; set; }
57-
58-
86+
public bool Subscriber3GotTheEvent { get; set; }
5987
public bool Subscriber1Subscribed { get; set; }
60-
6188
public bool Subscriber2Subscribed { get; set; }
89+
public bool Subscriber3Subscribed { get; set; }
6290
}
6391

6492
public class Publisher : EndpointConfigurationBuilder
@@ -69,6 +97,25 @@ public Publisher()
6997
}
7098
}
7199

100+
public class Subscriber3 : EndpointConfigurationBuilder
101+
{
102+
public Subscriber3()
103+
{
104+
EndpointSetup<DefaultServer>(c => Configure.Features.Disable<AutoSubscribe>())
105+
.AddMapping<IFoo>(typeof(Publisher));
106+
}
107+
108+
public class MyEventHandler : IHandleMessages<IFoo>
109+
{
110+
public Context Context { get; set; }
111+
112+
public void Handle(IFoo messageThatIsEnlisted)
113+
{
114+
Context.Subscriber3GotTheEvent = true;
115+
}
116+
}
117+
}
118+
72119
public class Subscriber1 : EndpointConfigurationBuilder
73120
{
74121
public Subscriber1()
@@ -107,6 +154,10 @@ public void Handle(MyEvent messageThatIsEnlisted)
107154
}
108155
}
109156

157+
public interface IFoo : IEvent
158+
{
159+
}
160+
110161
[Serializable]
111162
public class MyEvent : IEvent
112163
{

src/NServiceBus.Core/Licensing/LicenseLocationConventions.cs

+84-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static class LicenseLocationConventions
1212

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

1717
try
1818
{
@@ -71,25 +71,93 @@ public static string TryFindLicenseText()
7171
return NonLockingFileReader.ReadAllTextWithoutLocking(oldLocalLicenseFile);
7272
}
7373

74-
var hkcuLicense = GetHKCULicense();
74+
var registryLicence = LoadLicenseFromRegistry();
75+
if (!String.IsNullOrEmpty(registryLicence))
76+
{
77+
return registryLicence;
78+
}
79+
80+
registryLicence = LoadLicenseFromPreviousRegistryLocation("4.3");
81+
if (!String.IsNullOrEmpty(registryLicence))
82+
{
83+
return registryLicence;
84+
}
85+
86+
registryLicence = LoadLicenseFromPreviousRegistryLocation("4.2");
87+
if (!String.IsNullOrEmpty(registryLicence))
88+
{
89+
return registryLicence;
90+
}
91+
92+
registryLicence = LoadLicenseFromPreviousRegistryLocation("4.1");
93+
if (!String.IsNullOrEmpty(registryLicence))
94+
{
95+
return registryLicence;
96+
}
97+
98+
registryLicence = LoadLicenseFromPreviousRegistryLocation("4.0");
99+
if (!String.IsNullOrEmpty(registryLicence))
100+
{
101+
return registryLicence;
102+
}
103+
104+
return null;
105+
}
106+
107+
static string LoadLicenseFromRegistry()
108+
{
109+
var hkcuLicense = GetHKCULicense(@"ParticularSoftware\NServiceBus");
110+
111+
if (!String.IsNullOrEmpty(hkcuLicense))
112+
{
113+
Logger.Info(@"Using embedded license found in registry [HKEY_CURRENT_USER\Software\ParticularSoftware\NServiceBus\License].");
114+
115+
return hkcuLicense;
116+
}
117+
118+
var hklmLicense = GetHKLMLicense(@"ParticularSoftware\NServiceBus");
119+
if (!String.IsNullOrEmpty(hklmLicense))
120+
{
121+
Logger.Info(@"Using embedded license found in registry [HKEY_LOCAL_MACHINE\Software\ParticularSoftware\NServiceBus\License].");
122+
123+
return hklmLicense;
124+
}
125+
126+
return null;
127+
}
128+
129+
static string LoadLicenseFromPreviousRegistryLocation(string version)
130+
{
131+
var hkcuLicense = GetHKCULicense(subKey: version);
132+
75133
if (!String.IsNullOrEmpty(hkcuLicense))
76134
{
77-
Logger.InfoFormat(@"Using embedded license found in registry [HKEY_CURRENT_USER\Software\NServiceBus\{0}\License].", NServiceBusVersion.MajorAndMinor);
135+
Logger.InfoFormat(@"Using embedded license found in registry [HKEY_CURRENT_USER\Software\NServiceBus\{0}\License].", version);
136+
78137
return hkcuLicense;
79138
}
80139

81-
var hklmLicense = GetHKLMLicense();
140+
var hklmLicense = GetHKLMLicense(subKey: version);
82141
if (!String.IsNullOrEmpty(hklmLicense))
83142
{
84-
Logger.InfoFormat(@"Using embedded license found in registry [HKEY_LOCAL_MACHINE\Software\NServiceBus\{0}\License].", NServiceBusVersion.MajorAndMinor);
143+
Logger.InfoFormat(@"Using embedded license found in registry [HKEY_LOCAL_MACHINE\Software\NServiceBus\{0}\License].", version);
144+
85145
return hklmLicense;
86146
}
147+
87148
return null;
88149
}
89150

90-
public static string GetHKCULicense()
151+
static string GetHKCULicense(string softwareKey = "NServiceBus", string subKey = null)
91152
{
92-
using (var registryKey = Registry.CurrentUser.OpenSubKey(String.Format(@"SOFTWARE\NServiceBus\{0}", NServiceBusVersion.MajorAndMinor)))
153+
var keyPath = @"SOFTWARE\" + softwareKey;
154+
155+
if (subKey != null)
156+
{
157+
keyPath += @"\" + subKey;
158+
}
159+
160+
using (var registryKey = Registry.CurrentUser.OpenSubKey(keyPath))
93161
{
94162
if (registryKey != null)
95163
{
@@ -99,11 +167,18 @@ public static string GetHKCULicense()
99167
return null;
100168
}
101169

102-
public static string GetHKLMLicense()
170+
static string GetHKLMLicense(string softwareKey = "NServiceBus", string subKey = null)
103171
{
172+
var keyPath = @"SOFTWARE\" + softwareKey;
173+
174+
if (subKey != null)
175+
{
176+
keyPath += @"\" + subKey;
177+
}
178+
104179
try
105180
{
106-
using (var registryKey = Registry.LocalMachine.OpenSubKey(String.Format(@"SOFTWARE\NServiceBus\{0}", NServiceBusVersion.MajorAndMinor)))
181+
using (var registryKey = Registry.LocalMachine.OpenSubKey(keyPath))
107182
{
108183
if (registryKey != null)
109184
{

src/NServiceBus.Core/Unicast/UnicastBus.cs

+10-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ namespace NServiceBus.Unicast
1818
using Routing;
1919
using Satellites;
2020
using Serialization;
21-
using Settings;
2221
using Subscriptions;
2322
using Subscriptions.MessageDrivenSubscriptions.SubcriberSideFiltering;
2423
using Support;
@@ -281,18 +280,16 @@ public virtual void Publish<T>(T message)
281280
/// </summary>
282281
public virtual void Publish<T>()
283282
{
284-
Publish(new object[] { });
283+
Publish(CreateInstance<T>());
285284
}
286285

287286
/// <summary>
288287
/// Publishes the messages to all subscribers of the first message's type.
289288
/// </summary>
290289
public virtual void Publish<T>(params T[] messages)
291290
{
292-
293-
if (messages == null || messages.Length == 0) // Bus.Publish<IFoo>();
291+
if (messages == null || messages.Length == 0)
294292
{
295-
Publish(CreateInstance<T>(m => { }));
296293
return;
297294
}
298295

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

372-
if (TransportDefinition.HasSupportForCentralizedPubSub)
373-
{
369+
if (TransportDefinition.HasSupportForCentralizedPubSub && !IsAzureTransport())
370+
{
374371
// We are dealing with a brokered transport wired for auto pub/sub.
375372
SubscriptionManager.Subscribe(messageType, null);
376373
return;
@@ -398,6 +395,12 @@ public virtual void Subscribe(Type messageType, Predicate<object> condition)
398395
}
399396
}
400397

398+
[ObsoleteEx(RemoveInVersion = "5.0")]
399+
bool IsAzureTransport()
400+
{
401+
return TransportDefinition.GetType().Name.ToLower().Contains("azure");
402+
}
403+
401404
/// <summary>
402405
/// Unsubscribes from the given type of message - T.
403406
/// </summary>

src/licenseinstaller/Program.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ static bool TryToWriteToRegistry(string selectedLicenseText, RegistryView view)
6262
rootKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, view);
6363
}
6464

65-
using (
66-
var registryKey =
67-
rootKey.CreateSubKey(String.Format(@"SOFTWARE\NServiceBus\{0}", GetNServiceBusVersion().ToString(2))))
65+
using (var registryKey = rootKey.CreateSubKey(@"SOFTWARE\ParticularSoftware\NServiceBus"))
6866
{
6967
if (registryKey == null)
7068
{
@@ -87,7 +85,7 @@ static bool TryParseOptions(IEnumerable<string> args)
8785
{
8886
{
8987
"current-user|c",
90-
@"Installs license in HKEY_CURRENT_USER\SOFTWARE\NServiceBus, by default if not specified the license is installed in HKEY_LOCAL_MACHINE\SOFTWARE\NServiceBus"
88+
@"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"
9189
, s => action = () =>
9290
{
9391
useHKCU = true;

0 commit comments

Comments
 (0)