Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Host.AzureServiceBus] Modify user properties on failure / Supply reason and description on dead-letter #365

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

EtherZa
Copy link
Contributor

@EtherZa EtherZa commented Jan 29, 2025

#358 Added support for suppliying modified user properties with using an ASB transport when using a custom ServiceBusConsumerErrorHandler<T> implemntation and Failure().

public sealed class SampleConsumerErrorHandler<T> : ServiceBusConsumerErrorHandler<T>
{
    public override Task<ProcessResult> OnHandleError(T message, IConsumerContext consumerContext, Exception exception, int attempts)
    {
        var properties = new Dictionary<string, object>
        {
            { "Key", "value" },
            { "Attempts", attempts },
            { "SMB.Exception", exception.ToString().Substring(0, 1000) }
        };

        return Task.FromResult(Failure(properties));
    }
}

An option to supply a dead-letter reason/description when sending a message to the DLQ has also been included. If neither a reason nor description are supplied, it will fall back to the original implementation of exception type as the reason and exception message as the description.

public sealed class SampleConsumerErrorHandler<T> : ServiceBusConsumerErrorHandler<T>
{
    public override Task<ProcessResult> OnHandleError(T message, IConsumerContext consumerContext, Exception exception, int attempts)
    {
        return Task.FromResult(DeadLetter("reason", "description"));
    }
}

PS. It's great to see that v3 has escaped :)

@EtherZa EtherZa force-pushed the feature/358-failure-properties branch 2 times, most recently from 9679984 to ff082f0 Compare January 29, 2025 13:34
@zarusz
Copy link
Owner

zarusz commented Jan 29, 2025

Thanks for another great change that resolves #358!

I have a small suggestion for the documentation - once that’s addressed, I’ll be happy to merge.

Yes, v3 is out now! If you need this feature sooner, I can release it as 3.0.1 or a similar patch.

@EtherZa
Copy link
Contributor Author

EtherZa commented Jan 30, 2025

Hi @zarusz. The feature would be certainly be useful, but it's no rush if you have other plans/etc for a delayed release.

Signed-off-by: Richard Pringle <[email protected]>
@EtherZa EtherZa force-pushed the feature/358-failure-properties branch from 99e9013 to ef97ce2 Compare January 30, 2025 09:03
@zarusz zarusz merged commit 677cc30 into zarusz:master Jan 30, 2025
3 checks passed
@EtherZa
Copy link
Contributor Author

EtherZa commented Feb 3, 2025

Hi @zarusz. Is it too late to change my mind on an early release?

I've been told that my team is producing around 100gb of logs a day and reckon that I can reduce it substantially by dynamically changing the logging behaviour on a failure.

@zarusz
Copy link
Owner

zarusz commented Feb 3, 2025

Ok, let me push 3.0.1 today.

@EtherZa
Copy link
Contributor Author

EtherZa commented Feb 3, 2025

Fantastic! Thank you very much.

@zarusz
Copy link
Owner

zarusz commented Feb 3, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants