-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hotfix-3.0.3' into support-3.0
- Loading branch information
Showing
14 changed files
with
191 additions
and
27 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
54 changes: 54 additions & 0 deletions
54
src/NServiceBus.SqlServer.IntegrationTests/When_checking_schema.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,54 @@ | ||
namespace NServiceBus.SqlServer.AcceptanceTests.TransportTransaction | ||
{ | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using Transport.SQLServer; | ||
using Transport; | ||
|
||
public class When_checking_schema | ||
{ | ||
const string QueueTableName = "CheckingSchema"; | ||
|
||
TableBasedQueue queue; | ||
|
||
[SetUp] | ||
public async Task SetUp() | ||
{ | ||
var addressParser = new QueueAddressParser("dbo", null, null); | ||
|
||
await ResetQueue(addressParser); | ||
|
||
queue = new TableBasedQueue(addressParser.Parse(QueueTableName)); | ||
} | ||
|
||
[Test] | ||
public async Task It_returns_type_for_headers_column() | ||
{ | ||
using (var connection = await sqlConnectionFactory.OpenNewConnection()) | ||
{ | ||
var type = await queue.CheckHeadersColumnType(connection); | ||
|
||
Assert.AreEqual("nvarchar", type); | ||
} | ||
} | ||
|
||
static SqlConnectionFactory sqlConnectionFactory = SqlConnectionFactory.Default(@"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True"); | ||
|
||
static async Task ResetQueue(QueueAddressParser addressParser) | ||
{ | ||
var queueCreator = new QueueCreator(sqlConnectionFactory, addressParser); | ||
var queueBindings = new QueueBindings(); | ||
queueBindings.BindReceiving(QueueTableName); | ||
|
||
using (var connection = await sqlConnectionFactory.OpenNewConnection().ConfigureAwait(false)) | ||
{ | ||
using (var comm = connection.CreateCommand()) | ||
{ | ||
comm.CommandText = $"IF OBJECT_ID('{QueueTableName}', 'U') IS NOT NULL DROP TABLE {QueueTableName}"; | ||
comm.ExecuteNonQuery(); | ||
} | ||
} | ||
await queueCreator.CreateQueueIfNecessary(queueBindings, "").ConfigureAwait(false); | ||
} | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
src/NServiceBus.SqlServer.TransportTests/When_using_unicode_characters_in_headers.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,41 @@ | ||
namespace NServiceBus.TransportTests | ||
{ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using Transport; | ||
|
||
public class When_using_unicode_characters_in_headers : NServiceBusTransportTest | ||
{ | ||
[Test] | ||
public async Task Should_support_unicode_characters() | ||
{ | ||
var onMessageCalled = new TaskCompletionSource<MessageContext>(); | ||
|
||
await StartPump(m => | ||
{ | ||
onMessageCalled.SetResult(m); | ||
return Task.FromResult(0); | ||
}, | ||
error => Task.FromResult(ErrorHandleResult.Handled), | ||
TransportTransactionMode.None); | ||
|
||
var sentHeaders = new Dictionary<string, string> | ||
{ | ||
{ "a-B1", "a-B" }, | ||
{ "a-B2", "a-ɤϡ֎ᾣ♥-b" }, | ||
{ "a-ɤϡ֎ᾣ♥-B3", "a-B" }, | ||
{ "a-B4", "a-\U0001F60D-b" }, | ||
{ "a-\U0001F605-B5", "a-B" }, | ||
{ "a-B6", "a-😍-b" }, | ||
{ "a-😅-B7", "a-B" }, | ||
}; | ||
await SendMessage(InputQueueName, sentHeaders); | ||
|
||
var messageContext = await onMessageCalled.Task; | ||
|
||
Assert.IsNotEmpty(messageContext.Headers); | ||
CollectionAssert.IsSupersetOf(messageContext.Headers, sentHeaders); | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
namespace NServiceBus.Transport.SQLServer | ||
{ | ||
using System; | ||
using System.Data.SqlClient; | ||
using System.Threading.Tasks; | ||
using Logging; | ||
|
||
class SchemaInspector | ||
{ | ||
public SchemaInspector(Func<TableBasedQueue, Task<SqlConnection>> openConnection) | ||
{ | ||
this.openConnection = openConnection; | ||
} | ||
|
||
public async Task PerformInspection(TableBasedQueue queue) | ||
{ | ||
await VerifyExpiredIndex(queue).ConfigureAwait(false); | ||
await VerifyHeadersColumnType(queue).ConfigureAwait(false); | ||
} | ||
|
||
async Task VerifyExpiredIndex(TableBasedQueue queue) | ||
{ | ||
try | ||
{ | ||
using (var connection = await openConnection(queue).ConfigureAwait(false)) | ||
{ | ||
var indexExists = await queue.CheckExpiresIndexPresence(connection).ConfigureAwait(false); | ||
if (!indexExists) | ||
{ | ||
Logger.Warn($@"Table {queue} does not contain index 'Index_Expires'.{Environment.NewLine}Adding this index will speed up the process of purging expired messages from the queue. Please consult the documentation for further information."); | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.WarnFormat("Checking indexes on table {0} failed. Exception: {1}", queue, ex); | ||
} | ||
} | ||
|
||
async Task VerifyHeadersColumnType(TableBasedQueue queue) | ||
{ | ||
try | ||
{ | ||
using (var connection = await openConnection(queue).ConfigureAwait(false)) | ||
{ | ||
var columnType = await queue.CheckHeadersColumnType(connection).ConfigureAwait(false); | ||
if (string.Equals(columnType, "varchar", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
Logger.Warn($"Table {queue} stores headers in a non Unicode-compatible column (varchar).{Environment.NewLine}This may lead to data loss when sending non-ASCII characters in headers. SQL Server transport 3.1 and newer can take advantage of the nvarchar column type for headers. Please change the column type in the database."); | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.WarnFormat("Checking indexes on table {0} failed. Exception: {1}", queue, ex); | ||
} | ||
} | ||
|
||
Func<TableBasedQueue, Task<SqlConnection>> openConnection; | ||
static ILog Logger = LogManager.GetLogger<ExpiredMessagesPurger>(); | ||
} | ||
} |
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