SlimMessageBus icon indicating copy to clipboard operation
SlimMessageBus copied to clipboard

[Host.AzureServiceBus] Allow Passing Custom Properties in DeadLetter Response

Open przemyslaw-serwicki opened this issue 1 year ago • 3 comments

Description

Currently, when using Azure Service Bus (ASB) transport with a custom implementation of ServiceBusConsumerErrorHandler<T>, we can supply custom properties using the Failure response.

However, there is no equivalent way to pass custom properties when using DeadLetter.

It would be useful to have the ability to include additional attributes (key-value properties) in the DeadLetter response, similar to how it's done with Failure.

Proposed Change

Please enhance DeadLetter to allow passing custom properties as a dictionary

var properties = new Dictionary<string, object>
{
    { "SMB.Exception", exception.Message }
};

return Task.FromResult(DeadLetter("reason", "description", properties));

Reference Implementation

A similar feature was recently added for Failure responses: https://github.com/zarusz/SlimMessageBus/pull/365

przemyslaw-serwicki avatar Feb 07 '25 15:02 przemyslaw-serwicki

@przemyslaw-serwicki thanks for reporting.

@EtherZa any chance you could take this on and extend or shall I do?

zarusz avatar Feb 07 '25 17:02 zarusz

Unfortunately it's not supported by ASB. The only time that properties can be set is on creation of a new message and on abandon (Failure).

The closest we could come to overriding this limitation would be to pop a cloned message on the queue. ASB doesn't support sending a new message directly to the DLQ though, so it would then need to be added to the back of the FIFO queue to eventually be abandoned on processing -loosing sequence and timing in the process (while also being quite cumbersome).

The dead letter reason and description are the only properties that can be set when directing a message to the DLQ. Though not ideal, perhaps these can be leveraged to facilitate what @przemyslaw-serwicki is after? They are optional parameters on the DeadLetter method.

EtherZa avatar Feb 07 '25 23:02 EtherZa

@EtherZa @zarusz

Using reason and description properties is perfectly fine for me :)

Just thought it could be easy ehnancement.

przemyslaw-serwicki avatar Feb 10 '25 10:02 przemyslaw-serwicki