-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add snippets for SqlT v8 * Regenerate scripts * Get shared tests to work * Remove unused snippets * Tweaks --------- Co-authored-by: Brandon Ording <[email protected]>
- Loading branch information
1 parent
5bc0bae
commit 35b9aba
Showing
45 changed files
with
836 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
Snippets/SqlTransport/SqlTransport_6.1/SqlTransport_6.1.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net48</TargetFramework> | ||
<RootNamespace>SqlTransport_6._1</RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="NServiceBus.Transport.SqlServer" Version="6.1.*" /> | ||
<PackageReference Include="NUnit" Version="3.*" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="3.*" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.*" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.*" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" /> | ||
</ItemGroup> | ||
</Project> |
5 changes: 3 additions & 2 deletions
5
Snippets/SqlTransport/SqlTransport_6.2/SqlTransport_6.2.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net48</TargetFramework> | ||
<RootNamespace>SqlTransport_6._2</RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="NServiceBus.Transport.SqlServer" Version="6.2.*" /> | ||
<PackageReference Include="NUnit" Version="3.*" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="3.*" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.*" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.*" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" /> | ||
</ItemGroup> | ||
</Project> |
10 changes: 3 additions & 7 deletions
10
Snippets/SqlTransport/SqlTransport_6.3/SqlTransport_6.3.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net48</TargetFramework> | ||
<RootNamespace>SqlTransport_6._3</RootNamespace> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="NServiceBus.Transport.SqlServer" Version="6.3.*" /> | ||
<PackageReference Include="NUnit" Version="3.12.0" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" /> | ||
<PackageReference Include="NUnit" Version="3.*" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.*" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Snippets/SqlTransport/SqlTransport_8/ConfigurationSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using NServiceBus; | ||
|
||
class ConfigurationSettings | ||
{ | ||
ConfigurationSettings(EndpointConfiguration endpointConfiguration) | ||
{ | ||
#region sqlserver-TimeToWaitBeforeTriggeringCircuitBreaker | ||
|
||
var transport = new SqlServerTransport("connectionString") | ||
{ | ||
TimeToWaitBeforeTriggeringCircuitBreaker = TimeSpan.FromMinutes(3) | ||
}; | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!--startcode sqlserver-connection-string-xml--> | ||
<configuration> | ||
<connectionStrings> | ||
<add name="NServiceBus/Transport" | ||
connectionString="Data Source=instance; Initial Catalog=db; Integrated Security=True;Max Pool Size=80"/> | ||
</connectionStrings> | ||
</configuration> | ||
<!--endcode--> |
72 changes: 72 additions & 0 deletions
72
Snippets/SqlTransport/SqlTransport_8/CustomConnectionAndTransaction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using Microsoft.Data.SqlClient; | ||
using System.Threading.Tasks; | ||
using System.Transactions; | ||
using NServiceBus; | ||
|
||
class CustomConnectionAndTransaction | ||
{ | ||
async Task Usage(IMessageSession session, string connectionString, string commandText) | ||
{ | ||
#region UseCustomSqlConnectionAndTransaction | ||
|
||
using (var connection = new SqlConnection(connectionString)) | ||
{ | ||
connection.Open(); | ||
|
||
using (var transaction = connection.BeginTransaction()) | ||
{ | ||
var sqlCommand = new SqlCommand(commandText, connection, transaction); | ||
|
||
//Execute SQL statement | ||
sqlCommand.ExecuteNonQuery(); | ||
|
||
//Send a message | ||
var sendOptions = new SendOptions(); | ||
sendOptions.UseCustomSqlTransaction(transaction); | ||
await session.Send(new Message(), sendOptions); | ||
|
||
//Publish a message | ||
var publishOptions = new PublishOptions(); | ||
publishOptions.UseCustomSqlTransaction(transaction); | ||
await session.Publish(new Event(), publishOptions); | ||
|
||
transaction.Commit(); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region UseCustomSqlConnection | ||
|
||
using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, | ||
TransactionScopeAsyncFlowOption.Enabled)) | ||
{ | ||
using (var connection = new SqlConnection(connectionString)) | ||
{ | ||
connection.Open(); | ||
|
||
var sqlCommand = new SqlCommand(commandText, connection); | ||
|
||
//Execute SQL statement | ||
sqlCommand.ExecuteNonQuery(); | ||
|
||
//Send a message | ||
var sendOptions = new SendOptions(); | ||
sendOptions.UseCustomSqlConnection(connection); | ||
await session.Send(new Message(), sendOptions); | ||
|
||
//Publish a message | ||
var publishOptions = new PublishOptions(); | ||
publishOptions.UseCustomSqlConnection(connection); | ||
await session.Publish(new Event(), publishOptions); | ||
} | ||
|
||
scope.Complete(); | ||
} | ||
|
||
#endregion | ||
} | ||
|
||
class Message { }; | ||
class Event { }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using NServiceBus; | ||
|
||
class DefaultCatalog | ||
{ | ||
void OverwriteDefaultCatalog() | ||
{ | ||
#region sqlserver-default-catalog | ||
|
||
var transport = new SqlServerTransport("connectionString") | ||
{ | ||
DefaultCatalog = "mycatalog" | ||
}; | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using NServiceBus; | ||
|
||
class DelayConfig | ||
{ | ||
void ConfigurePeekDelay(EndpointConfiguration endpointConfiguration) | ||
{ | ||
#region sqlserver-queue-peeker-config-delay | ||
|
||
var transport = new SqlServerTransport("connectionString") | ||
{ | ||
QueuePeeker = | ||
{ | ||
Delay = TimeSpan.FromSeconds(5) | ||
} | ||
}; | ||
|
||
#endregion | ||
} | ||
|
||
void ConfigurePeekBatchSize(EndpointConfiguration endpointConfiguration) | ||
{ | ||
#region sqlserver-queue-peeker-config-batch-size | ||
|
||
var transport = new SqlServerTransport("connectionString") | ||
{ | ||
QueuePeeker = | ||
{ | ||
MaxRecordsToPeek = 50 | ||
} | ||
}; | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using NServiceBus; | ||
|
||
class DelayedDelivery | ||
{ | ||
void Configure(EndpointConfiguration endpointConfiguration) | ||
{ | ||
var transport = new SqlServerTransport(""); | ||
|
||
#region DelayedDeliveryTableSuffix | ||
|
||
transport.DelayedDelivery.TableSuffix = "Delayed"; | ||
|
||
#endregion | ||
|
||
#region DelayedDeliveryBatchSize | ||
|
||
transport.DelayedDelivery.BatchSize = 100; | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using NServiceBus; | ||
|
||
class DiscardMessages | ||
{ | ||
void Configure(EndpointConfiguration endpointConfiguration) | ||
{ | ||
#region purge-expired-on-startup | ||
|
||
var transport = new SqlServerTransport("connectionString") | ||
{ | ||
ExpiredMessagesPurger = | ||
{ | ||
PurgeOnStartup = true, | ||
PurgeBatchSize = 5000 | ||
} | ||
}; | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--startcode sql-ExpiresIndex | ||
create nonclustered index [Index_Expires] | ||
on [schema].[queuename] | ||
( | ||
[Expires] asc | ||
) | ||
include | ||
( | ||
[Id], | ||
[RowVersion] | ||
) | ||
--endcode |
Oops, something went wrong.