diff --git a/.gitignore b/.gitignore index 1a2e20de5..a9137e1d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ nugets +deploy build32 binaries obj diff --git a/Octopus/DeploymentProcess.json b/Octopus/DeploymentProcess.json new file mode 100644 index 000000000..503a70e49 --- /dev/null +++ b/Octopus/DeploymentProcess.json @@ -0,0 +1,88 @@ +{ + "Steps": [ + { + "Id": "b3339d4f-563f-49ac-b759-554619554f9d", + "Name": "Deploy", + "RequiresPackagesToBeAcquired": false, + "Properties": { + "Octopus.Action.TargetRoles": "tentacle" + }, + "Condition": "Success", + "Actions": [ + { + "Id": "f57466ee-18c3-4f89-9aa9-153814528a44", + "Name": "Deploy", + "ActionType": "Octopus.TentaclePackage", + "Environments": [], + "Properties": { + "Octopus.Action.Package.NuGetFeedId": "feeds-1", + "Octopus.Action.EnabledFeatures": "Octopus.Features.ConfigurationTransforms,Octopus.Features.ConfigurationVariables", + "Octopus.Action.Package.AutomaticallyRunConfigurationTransformationFiles": "False", + "Octopus.Action.Package.AutomaticallyUpdateAppSettingsAndConnectionStrings": "False", + "Octopus.Action.Package.DownloadOnTentacle": "False", + "Octopus.Action.Package.NuGetPackageId": "%PROJECT_NAME%.Deploy" + }, + "SensitiveProperties": {} + } + ], + "SensitiveProperties": {} + }, + { + "Id": "674e1a63-42cf-440e-83be-f80f58ef85a1", + "Name": "Notify of draft", + "RequiresPackagesToBeAcquired": false, + "Properties": { + "Octopus.Action.TargetRoles": "tentacle" + }, + "Condition": "Success", + "Actions": [ + { + "Id": "578efb8c-8303-4c1f-88a9-f3cee9e14e0a", + "Name": "Notify of draft", + "ActionType": "Octopus.Script", + "Environments": [ + "Environments-65" + ], + "Properties": { + "Octopus.Action.Script.ScriptBody": "$message = if ($OctopusParameters['HipChatMessage']) { $OctopusParameters['HipChatMessage'] } else { \"(successful) %PROJECT_NAME% [v$($OctopusParameters['Octopus.Release.Number'])] deployed to $($OctopusParameters['Octopus.Environment.Name']) on $($OctopusParameters['Octopus.Machine.Name'])\" } \n#---------\n$apitoken = $OctopusParameters['HipChatAuthToken']\n$roomid = $OctopusParameters['HipChatRoomId']\n$from = $OctopusParameters['HipChatFrom']\n$colour = $OctopusParameters['HipChatColor']\n\nTry \n{\n\t#Do the HTTP POST to HipChat\n\t$post = \"auth_token=$apitoken&room_id=$roomid&from=$from&color=$colour&message=$message¬ify=1&message_format=text\"\n\t$webRequest = [System.Net.WebRequest]::Create(\"https://api.hipchat.com/v1/rooms/message\")\n\t$webRequest.ContentType = \"application/x-www-form-urlencoded\"\n\t$postStr = [System.Text.Encoding]::UTF8.GetBytes($post)\n\t$webrequest.ContentLength = $postStr.Length\n\t$webRequest.Method = \"POST\"\n\t$requestStream = $webRequest.GetRequestStream()\n\t$requestStream.Write($postStr, 0,$postStr.length)\n\t$requestStream.Close()\n\t\n\t[System.Net.WebResponse] $resp = $webRequest.GetResponse();\n\t$rs = $resp.GetResponseStream();\n\t[System.IO.StreamReader] $sr = New-Object System.IO.StreamReader -argumentList $rs;\n\t$sr.ReadToEnd();\t\t\t\t\t\n}\ncatch [Exception] {\n\t\"Woah!, wasn't expecting to get this exception. `r`n $_.Exception.ToString()\"\n}", + "Octopus.Action.Template.Id": "ActionTemplates-2", + "Octopus.Action.Template.Version": "0", + "HipChatFrom": "Octopus Deploy", + "HipChatColor": "green", + "HipChatRoomId": "#{HipChatEngineeringID}", + "HipChatAuthToken": "#{HipChatAPIV1}", + "HipChatMessage": "New draft release of %PROJECT_NAME% at https://github.com/Particular/%PROJECT_NAME%/releases" + }, + "SensitiveProperties": {} + } + ], + "SensitiveProperties": {} + }, + { + "Id": "b6145394-b751-4d2e-8a92-1b82f1a3fc9a", + "Name": "Verify draft", + "RequiresPackagesToBeAcquired": false, + "Properties": { + "Octopus.Action.TargetRoles": "" + }, + "Condition": "Success", + "Actions": [ + { + "Id": "737fa883-457b-4821-805a-ade60e58e181", + "Name": "Verify draft", + "ActionType": "Octopus.Manual", + "Environments": [ + "Environments-65" + ], + "Properties": { + "Octopus.Action.Manual.ResponsibleTeamIds": "teams-everyone", + "Octopus.Action.Manual.Instructions": "Please verify the draft release notes of %PROJECT_NAME% at https://github.com/Particular/%PROJECT_NAME%/releases" + }, + "SensitiveProperties": {} + } + ], + "SensitiveProperties": {} + } + ], + "Version" : "%VERSION%" +} diff --git a/Octopus/Project.json b/Octopus/Project.json new file mode 100644 index 000000000..1d9c27175 --- /dev/null +++ b/Octopus/Project.json @@ -0,0 +1,18 @@ +{ + "IncludedLibraryVariableSetIds": [ + "LibraryVariableSets-33", + "LibraryVariableSets-36", + "LibraryVariableSets-35", + "LibraryVariableSets-65", + "LibraryVariableSets-67" + ], + "DefaultToSkipIfAlreadyInstalled": false, + "VersioningStrategy": { + "DonorPackageStepId": null, + "Template": "#{Octopus.Version.LastMajor}.#{Octopus.Version.LastMinor}.#{Octopus.Version.NextPatch}" + }, + "Name": "%OCTO_PROJECT_NAME%", + "Description": "", + "IsDisabled": false, + "ProjectGroupId": "ProjectGroups-99", +} \ No newline at end of file diff --git a/packaging/nuget/NServiceBus.Transports.SQLServer.nuspec b/packaging/nuget/NServiceBus.SqlServer.nuspec similarity index 95% rename from packaging/nuget/NServiceBus.Transports.SQLServer.nuspec rename to packaging/nuget/NServiceBus.SqlServer.nuspec index 5183a4406..d6d6c68be 100644 --- a/packaging/nuget/NServiceBus.Transports.SQLServer.nuspec +++ b/packaging/nuget/NServiceBus.SqlServer.nuspec @@ -20,7 +20,7 @@ - + diff --git a/src/.nuget/packages.config b/src/.nuget/packages.config index 0901fded1..1610affb5 100644 --- a/src/.nuget/packages.config +++ b/src/.nuget/packages.config @@ -1,4 +1,6 @@  + + \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.0.0/EndpointTemplates/ConfigureExtensions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.0.0/EndpointTemplates/ConfigureExtensions.cs index 956c35484..7d9c372f4 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.0.0/EndpointTemplates/ConfigureExtensions.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.0.0/EndpointTemplates/ConfigureExtensions.cs @@ -16,13 +16,27 @@ public static string GetOrNull(this IDictionary dictionary, stri return dictionary[key]; } - public static void DefineTransport(this BusConfiguration builder, IDictionary settings) + public static void DefineTransport(this BusConfiguration builder, IDictionary settings, Type endpointBuilderType) { if (!settings.ContainsKey("Transport")) { settings = Transports.Default.Settings; } + const string typeName = "ConfigureTransport"; + + var configurerType = endpointBuilderType.GetNestedType(typeName); + + if (configurerType != null) + { + var configurer = Activator.CreateInstance(configurerType); + + dynamic dc = configurer; + + dc.Configure(builder); + return; + } + var transportType = Type.GetType(settings["Transport"]); builder.UseTransport(transportType).ConnectionString(settings["Transport.ConnectionString"]); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.0.0/EndpointTemplates/DefaultServer.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.0.0/EndpointTemplates/DefaultServer.cs index 10459cc15..173d3dc03 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.0.0/EndpointTemplates/DefaultServer.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.0.0/EndpointTemplates/DefaultServer.cs @@ -42,7 +42,7 @@ public BusConfiguration GetConfiguration(RunDescriptor runDescriptor, EndpointCo builder.TypesToScan(typesToInclude); builder.CustomConfigurationSource(configSource); builder.EnableInstallers(); - builder.DefineTransport(settings); + builder.DefineTransport(settings, endpointConfiguration.BuilderType); builder.DefineBuilder(settings); builder.RegisterComponents(r => { diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj b/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj index e394751e1..b32cb2d9e 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj +++ b/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj @@ -172,6 +172,7 @@ + diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/When_using_different_connection_strings_for_each_endpoint.cs b/src/NServiceBus.SqlServer.AcceptanceTests/When_using_different_connection_strings_for_each_endpoint.cs new file mode 100644 index 000000000..ff9a8018b --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/When_using_different_connection_strings_for_each_endpoint.cs @@ -0,0 +1,126 @@ +namespace NServiceBus.AcceptanceTests.Basic +{ + using System; + using System.Configuration; + using System.Reflection; + using NServiceBus.AcceptanceTesting; + using NServiceBus.AcceptanceTests.EndpointTemplates; + using NUnit.Framework; + + public class When_using_different_connection_strings_for_each_endpoint : NServiceBusAcceptanceTest + { + const string ClientConnectionString = @"Server=localhost\sqlexpress;Database=nservicebus1;Trusted_Connection=True;"; + const string ServerConnectionString = @"Server=localhost\sqlexpress;Database=nservicebus2;Trusted_Connection=True;"; + + [Test] + public void Should_use_configured_connection_string_when_replying() + { + + var context = new Context() + { + Id = Guid.NewGuid() + }; + + Scenario.Define(context) + .WithEndpoint(b => b.CustomConfig(c => AddConnectionString("NServiceBus/Transport/Basic.Sender.WhenUsingDifferentConnectionStringsForEachEndpoint.SqlServerTransport", ClientConnectionString))) + .WithEndpoint(b => b.CustomConfig(c => AddConnectionString("NServiceBus/Transport/Basic.Receiver.WhenUsingDifferentConnectionStringsForEachEndpoint.SqlServerTransport", ServerConnectionString)).Given((bus, c) => bus.Send(new MyRequest + { + ContextId = c.Id + }))) + .Done(c => context.GotResponse) + .Run(); + } + + static void AddConnectionString(string name, string value) + { + var connectionStrings = ConfigurationManager.ConnectionStrings; + //Setting the read only field to false via reflection in order to modify the connection strings + var readOnlyField = typeof(ConfigurationElementCollection).GetField("bReadOnly", BindingFlags.Instance | BindingFlags.NonPublic); + readOnlyField.SetValue(connectionStrings, false); + connectionStrings.Add(new ConnectionStringSettings(name, value)); + } + + public class Sender : EndpointConfigurationBuilder + { + public Sender() + { + EndpointSetup() + .AddMapping(typeof(Receiver)); + } + + public class ConfigureTransport + { + public void Configure(BusConfiguration busConfiguration) + { + busConfiguration.UseTransport().ConnectionString(ClientConnectionString); + } + } + + class MyReplyHandler : IHandleMessages + { + public IBus Bus { get; set; } + public Context Context { get; set; } + + public void Handle(MyReply message) + { + if (Context.Id != message.ContextId) + { + return; + } + Context.GotResponse = true; + } + } + } + + public class Receiver : EndpointConfigurationBuilder + { + public Receiver() + { + EndpointSetup(); + } + + public class ConfigureTransport + { + public void Configure(BusConfiguration busConfiguration) + { + busConfiguration.UseTransport().ConnectionString(ServerConnectionString); + busConfiguration.Transactions().DisableDistributedTransactions(); + } + } + + class MyEventHandler : IHandleMessages + { + public IBus Bus { get; set; } + public Context Context { get; set; } + + public void Handle(MyRequest message) + { + if (Context.Id != message.ContextId) + { + return; + } + Bus.Reply(new MyReply + { + ContextId = message.ContextId + }); + } + } + } + + class MyRequest : IMessage + { + public Guid ContextId { get; set; } + } + + class MyReply : IMessage + { + public Guid ContextId { get; set; } + } + + class Context : ScenarioContext + { + public bool GotResponse { get; set; } + public Guid Id { get; set; } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.sln.DotSettings b/src/NServiceBus.SqlServer.sln.DotSettings index 411e1127c..92c1c7eca 100644 --- a/src/NServiceBus.SqlServer.sln.DotSettings +++ b/src/NServiceBus.SqlServer.sln.DotSettings @@ -125,6 +125,13 @@ ERROR ERROR ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR <?xml version="1.0" encoding="utf-16"?><Profile name="Format My Code Using &quot;Particular&quot; conventions"><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_IMPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSReorderTypeMembers>True</CSReorderTypeMembers><JsInsertSemicolon>True</JsInsertSemicolon><JsReformatCode>True</JsReformatCode><CssReformatCode>True</CssReformatCode><CSArrangeThisQualifier>True</CSArrangeThisQualifier><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><HtmlReformatCode>True</HtmlReformatCode><CSShortenReferences>True</CSShortenReferences><CSharpFormatDocComments>True</CSharpFormatDocComments><CssAlphabetizeProperties>True</CssAlphabetizeProperties></Profile> Default: Reformat Code Format My Code Using "Particular" conventions diff --git a/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj b/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj index 2c46951c1..38f3c3ce8 100644 --- a/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj +++ b/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj @@ -15,7 +15,7 @@ $(SolutionDir)NServiceBus.snk ..\ - 76193a81 + 60004136 true @@ -94,9 +94,9 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + - - + + \ No newline at end of file diff --git a/src/NServiceBus.SqlServer/SqlServerMessageSender.cs b/src/NServiceBus.SqlServer/SqlServerMessageSender.cs index 3df180b96..1e27204eb 100644 --- a/src/NServiceBus.SqlServer/SqlServerMessageSender.cs +++ b/src/NServiceBus.SqlServer/SqlServerMessageSender.cs @@ -32,7 +32,7 @@ public SqlServerMessageSender() public void Send(TransportMessage message, SendOptions sendOptions) { var address = sendOptions.Destination; - + var connectionStringKey = sendOptions.Destination.Queue; string callbackAddress; if (sendOptions.GetType().FullName.EndsWith("ReplyOptions") && @@ -46,14 +46,13 @@ public void Send(TransportMessage message, SendOptions sendOptions) { message.Headers[CallbackHeaderKey] = CallbackQueue; } - var queue = address.Queue; try { //If there is a connectionstring configured for the queue, use that connectionstring var queueConnectionString = DefaultConnectionString; - if (ConnectionStringCollection.Keys.Contains(queue)) + if (ConnectionStringCollection.Keys.Contains(connectionStringKey)) { - queueConnectionString = ConnectionStringCollection[queue]; + queueConnectionString = ConnectionStringCollection[connectionStringKey]; } if (sendOptions.EnlistInReceiveTransaction) diff --git a/src/NServiceBus.SqlServer/packages.config b/src/NServiceBus.SqlServer/packages.config index 25a2a338a..082ad9202 100644 --- a/src/NServiceBus.SqlServer/packages.config +++ b/src/NServiceBus.SqlServer/packages.config @@ -1,8 +1,8 @@  - + - + \ No newline at end of file diff --git a/src/NuGet.Config b/src/NuGet.Config deleted file mode 100644 index 5e6dda222..000000000 --- a/src/NuGet.Config +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/nuget.config b/src/nuget.config index 5e6dda222..9f16f776e 100644 --- a/src/nuget.config +++ b/src/nuget.config @@ -6,9 +6,8 @@ - - +