static bool HasReachedMaxTime(IncomingMessage message)
{
string timestampHeader;
if (!message.Headers.TryGetValue(Headers.DelayedRetriesTimestamp, out timestampHeader))
{
return false;
}
if (string.IsNullOrEmpty(timestampHeader))
{
return false;
}
try
{
var handledAt = DateTimeExtensions.ToUtcDateTime(timestampHeader);
var now = DateTime.UtcNow;
if (now > handledAt.AddDays(1))
{
return true;
}
}
// ReSharper disable once EmptyGeneralCatchClause
// this code won't usually throw but in case a user has decided to hack a message/headers and for some bizarre reason
// they changed the date and that parse fails, we want to make sure that doesn't prevent the message from being
// forwarded to the error queue.
catch (Exception)
{
}
return false;
}