Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Wolverine.AmazonSqs.Internal;

public class AmazonSqsTransport : BrokerTransport<AmazonSqsQueue>
{
public const string DeadLetterQueueName = "wolverine-dead-letter-queue";
public const string DeadLetterQueueName = DeadLetterQueueConstants.DefaultQueueName;

public const char Separator = '-';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public partial class AzureServiceBusTransport : BrokerTransport<AzureServiceBusE

public readonly List<AzureServiceBusSubscription> Subscriptions = new();
private string _hostName;
public const string DeadLetterQueueName = "wolverine-dead-letter-queue";
public const string DeadLetterQueueName = DeadLetterQueueConstants.DefaultQueueName;

public AzureServiceBusTransport() : this(ProtocolName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ public async Task MoveToErrorsAsync(Envelope envelope, Exception exception)
var message = await _endpoint.EnvelopeMapper!.CreateMessage(envelope);

message.Headers ??= new Headers();
message.Headers.Add("exception-type", Encoding.UTF8.GetBytes(exception.GetType().FullName ?? "Unknown"));
message.Headers.Add("exception-message", Encoding.UTF8.GetBytes(exception.Message));
message.Headers.Add("exception-stack", Encoding.UTF8.GetBytes(exception.StackTrace ?? ""));
message.Headers.Add("failed-at", Encoding.UTF8.GetBytes(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString()));
message.Headers.Add(DeadLetterQueueConstants.ExceptionTypeHeader, Encoding.UTF8.GetBytes(exception.GetType().FullName ?? "Unknown"));
message.Headers.Add(DeadLetterQueueConstants.ExceptionMessageHeader, Encoding.UTF8.GetBytes(exception.Message));
message.Headers.Add(DeadLetterQueueConstants.ExceptionStackHeader, Encoding.UTF8.GetBytes(exception.StackTrace ?? ""));
message.Headers.Add(DeadLetterQueueConstants.FailedAtHeader, Encoding.UTF8.GetBytes(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString()));

using var producer = transport.CreateProducer(_endpoint.GetEffectiveProducerConfig());
await producer.ProduceAsync(dlqTopicName, message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public KafkaTransport(string protocol) : base(protocol, "Kafka Topics", ["kafka"
/// The Kafka topic name used for native dead letter queue messages.
/// Default is "wolverine-dead-letter-queue".
/// </summary>
public string DeadLetterQueueTopicName { get; set; } = "wolverine-dead-letter-queue";
public string DeadLetterQueueTopicName { get; set; } = DeadLetterQueueConstants.DefaultQueueName;

public KafkaUsage Usage { get; set; } = KafkaUsage.ProduceAndConsume;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public partial class RabbitMqTransport : BrokerTransport<RabbitMqEndpoint>, IAsy
{
public const string ProtocolName = "rabbitmq";
public const string ResponseEndpointName = "RabbitMqResponses";
public const string DeadLetterQueueName = "wolverine-dead-letter-queue";
public const string DeadLetterQueueName = DeadLetterQueueConstants.DefaultQueueName;
public const string DeadLetterQueueHeader = "x-dead-letter-exchange";
public const string QueueTypeHeader = "x-queue-type";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public async Task MoveToErrorsAsync(Envelope envelope, Exception exception)
var fields = new List<NameValueEntry>
{
new("envelope", serializedEnvelope),
new("exception-type", exception.GetType().FullName ?? "Unknown"),
new("exception-message", exception.Message ?? ""),
new("exception-stack", exception.StackTrace ?? ""),
new("failed-at", DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString()),
new(DeadLetterQueueConstants.ExceptionTypeHeader, exception.GetType().FullName ?? "Unknown"),
new(DeadLetterQueueConstants.ExceptionMessageHeader, exception.Message ?? ""),
new(DeadLetterQueueConstants.ExceptionStackHeader, exception.StackTrace ?? ""),
new(DeadLetterQueueConstants.FailedAtHeader, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString()),
new("message-type", envelope.MessageType ?? "Unknown"),
new("envelope-id", envelope.Id.ToString()),
new("attempts", envelope.Attempts.ToString())
Expand Down
29 changes: 29 additions & 0 deletions src/Wolverine/Transports/DeadLetterQueueConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Wolverine.Transports;

public static class DeadLetterQueueConstants
{
/// <summary>
/// The default queue/topic name used for dead letter queues across all transports.
/// </summary>
public const string DefaultQueueName = "wolverine-dead-letter-queue";

/// <summary>
/// Header key for the full type name of the exception that caused the message to fail.
/// </summary>
public const string ExceptionTypeHeader = "exception-type";

/// <summary>
/// Header key for the exception message.
/// </summary>
public const string ExceptionMessageHeader = "exception-message";

/// <summary>
/// Header key for the exception stack trace.
/// </summary>
public const string ExceptionStackHeader = "exception-stack";

/// <summary>
/// Header key for the Unix timestamp in milliseconds when the failure occurred.
/// </summary>
public const string FailedAtHeader = "failed-at";
}
Loading