diff --git a/src/NServiceBus.SqlServer/DelayedDelivery/StoreDelayedMessageCommand.cs b/src/NServiceBus.SqlServer/DelayedDelivery/StoreDelayedMessageCommand.cs index b89d4ee21..31ea71c0f 100644 --- a/src/NServiceBus.SqlServer/DelayedDelivery/StoreDelayedMessageCommand.cs +++ b/src/NServiceBus.SqlServer/DelayedDelivery/StoreDelayedMessageCommand.cs @@ -27,7 +27,11 @@ public void PrepareSendCommand(SqlCommand command) { AddParameter(command, "Headers", SqlDbType.NVarChar, headers); AddParameter(command, "Body", SqlDbType.VarBinary, bodyBytes); - AddParameter(command, "DueAfterMs", SqlDbType.BigInt, dueAfter.TotalMilliseconds); + AddParameter(command, "DueAfterDays", SqlDbType.Int, dueAfter.Days); + AddParameter(command, "DueAfterHours", SqlDbType.Int, dueAfter.Hours); + AddParameter(command, "DueAfterMinutes", SqlDbType.Int, dueAfter.Minutes); + AddParameter(command, "DueAfterSeconds", SqlDbType.Int, dueAfter.Seconds); + AddParameter(command, "DueAfterMilliseconds", SqlDbType.Int, dueAfter.Milliseconds); } void AddParameter(SqlCommand command, string name, SqlDbType type, object value) diff --git a/src/NServiceBus.SqlServer/Queuing/SqlConstants.cs b/src/NServiceBus.SqlServer/Queuing/SqlConstants.cs index f85e403c4..e2686b91e 100644 --- a/src/NServiceBus.SqlServer/Queuing/SqlConstants.cs +++ b/src/NServiceBus.SqlServer/Queuing/SqlConstants.cs @@ -44,6 +44,13 @@ THEN DATEADD(ms, @TimeToBeReceivedMs, GETUTCDATE()) END, IF ( (512 & @@OPTIONS) = 512 ) SET @NOCOUNT = 'ON' SET NOCOUNT ON; +DECLARE @DueAfter DATETIME = GETUTCDATE(); +SET @DueAfter = DATEADD(ms, @DueAfterMilliseconds, @DueAfter); +SET @DueAfter = DATEADD(s, @DueAfterSeconds, @DueAfter); +SET @DueAfter = DATEADD(n, @DueAfterMinutes, @DueAfter); +SET @DueAfter = DATEADD(hh, @DueAfterHours, @DueAfter); +SET @DueAfter = DATEADD(d, @DueAfterDays, @DueAfter); + INSERT INTO {0} ( Headers, Body, @@ -51,7 +58,7 @@ THEN DATEADD(ms, @TimeToBeReceivedMs, GETUTCDATE()) END, VALUES ( @Headers, @Body, - DATEADD(ms, @DueAfterMs, GETUTCDATE())); + @DueAfter); IF(@NOCOUNT = 'ON') SET NOCOUNT ON; IF(@NOCOUNT = 'OFF') SET NOCOUNT OFF;";