diff --git a/src/ServiceControl/CombGuid.cs b/src/ServiceControl/CombGuid.cs deleted file mode 100644 index fde451f80c..0000000000 --- a/src/ServiceControl/CombGuid.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace NServiceBus -{ - using System; - - /// - /// Generates a Guid using http://www.informit.com/articles/article.asp?p=25862 - /// The Comb algorithm is designed to make the use of s as Primary Keys, Foreign Keys, and Indexes - /// nearly as efficient - /// as . - /// - /// Source: https://github.com/nhibernate/nhibernate-core/blob/4.0.4.GA/src/NHibernate/Id/GuidCombGenerator.cs - static class CombGuid - { - /// - /// Generate a new using the comb algorithm. - /// - public static Guid Generate() - { - var guidArray = Guid.NewGuid().ToByteArray(); - - var now = DateTime.UtcNow; - - // Get the days and milliseconds which will be used to build the byte string - var days = new TimeSpan(now.Ticks - BaseDateTicks); - var timeOfDay = now.TimeOfDay; - - // Convert to a byte array - // Note that SQL Server is accurate to 1/300th of a millisecond so we divide by 3.333333 - var daysArray = BitConverter.GetBytes(days.Days); - var millisecondArray = BitConverter.GetBytes((long)(timeOfDay.TotalMilliseconds / 3.333333)); - - // Reverse the bytes to match SQL Servers ordering - Array.Reverse(daysArray); - Array.Reverse(millisecondArray); - - // Copy the bytes into the guid - Array.Copy(daysArray, daysArray.Length - 2, guidArray, guidArray.Length - 6, 2); - Array.Copy(millisecondArray, millisecondArray.Length - 4, guidArray, guidArray.Length - 4, 4); - - return new Guid(guidArray); - } - - static readonly long BaseDateTicks = new DateTime(1900, 1, 1).Ticks; - } -} \ No newline at end of file diff --git a/src/ServiceControl/Recoverability/Editing/EditHandler.cs b/src/ServiceControl/Recoverability/Editing/EditHandler.cs index 67d2ddba55..19a8827afb 100644 --- a/src/ServiceControl/Recoverability/Editing/EditHandler.cs +++ b/src/ServiceControl/Recoverability/Editing/EditHandler.cs @@ -7,7 +7,6 @@ using Contracts.MessageFailures; using Infrastructure.Auth; using Infrastructure.DomainEvents; - using MessageFailures; using Microsoft.Extensions.Logging; using NServiceBus; using NServiceBus.Routing; @@ -80,10 +79,10 @@ await domainEvents.Raise(new MessageEditedAndRetried OutgoingMessage BuildMessage(EditAndSend message) { - var messageId = CombGuid.Generate().ToString(); + var messageId = Guid.CreateVersion7().ToString("D"); var headers = HeaderFilter.RemoveErrorMessageHeaders(message.NewHeaders); corruptedReplyToHeaderStrategy.FixCorruptedReplyToHeader(headers); - headers[Headers.MessageId] = Guid.NewGuid().ToString("D"); + headers[Headers.MessageId] = messageId; var body = Convert.FromBase64String(message.NewBody); var outgoingMessage = new OutgoingMessage(messageId, headers, body);