Skip to content

Commit

Permalink
Merge branch 'hotfix-3.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymonPobiega committed Jul 13, 2017
2 parents 0260413 + 0ea01eb commit c2ca654
Showing 1 changed file with 45 additions and 31 deletions.
76 changes: 45 additions & 31 deletions src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacySql.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,54 @@ namespace NServiceBus.Transport.SQLServer
{
class LegacySql
{
internal const string CreateQueueText = @"IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{0}') AND type in (N'U'))
BEGIN
EXEC sp_getapplock @Resource = '{0}_lock', @LockMode = 'Exclusive'
public static readonly string CreateQueueText = @"
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'{0}')
AND type in (N'U'))
RETURN
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{0}') AND type in (N'U'))
BEGIN
CREATE TABLE {0}(
[Id] [uniqueidentifier] NOT NULL,
[CorrelationId] [varchar](255),
[ReplyToAddress] [varchar](255),
[Recoverable] [bit] NOT NULL,
[Expires] [datetime],
[Headers] [varchar](max) NOT NULL,
[Body] [varbinary](max),
[RowVersion] [bigint] IDENTITY(1,1) NOT NULL
);
EXEC sp_getapplock @Resource = '{0}_lock', @LockMode = 'Exclusive'
CREATE CLUSTERED INDEX [Index_RowVersion] ON {0}
(
[RowVersion]
)
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'{0}')
AND type in (N'U'))
BEGIN
EXEC sp_releaseapplock @Resource = '{0}_lock'
RETURN
END
CREATE NONCLUSTERED INDEX [Index_Expires] ON {0}
(
[Expires]
)
INCLUDE
(
[Id],
[RowVersion]
)
END
CREATE TABLE {0} (
Id uniqueidentifier NOT NULL,
CorrelationId varchar(255),
ReplyToAddress varchar(255),
Recoverable bit NOT NULL,
Expires datetime,
Headers nvarchar(max) NOT NULL,
Body varbinary(max),
RowVersion bigint IDENTITY(1,1) NOT NULL
);
EXEC sp_releaseapplock @Resource = '{0}_lock'
END";
CREATE CLUSTERED INDEX Index_RowVersion ON {0}
(
RowVersion
)
CREATE NONCLUSTERED INDEX Index_Expires ON {0}
(
Expires
)
INCLUDE
(
Id,
RowVersion
)
WHERE
Expires IS NOT NULL
EXEC sp_releaseapplock @Resource = '{0}_lock'";
}
}

0 comments on commit c2ca654

Please sign in to comment.