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] Abandon/dead letter (#356) #357

Merged
merged 1 commit into from
Jan 1, 2025

Conversation

EtherZa
Copy link
Contributor

@EtherZa EtherZa commented Jan 1, 2025

Added Abandon response to ConsumerErrorHandlerResult to be used by supported transports to dead letter the message. Most transports don't support the feature without some form of customised flow, but ASB and RabbitMQ both do.

Azure Service Bus
Implemented without restriction. Abandoned messages will be sent directly to the DLQ, failed messages will be retried until their maximum delivery count has been exceeded.

RabbitMQ
I don't have any experience with RabbitMQ, so I may have missed something; but the bus does not appear to limit how many times a message will be delivered if it is Nacked with requeue = true. As such, changing the code to fail with a requeue would be a dangerous breaking change as it could lead to an inifinite recursion in message processing for exisiting SMB users (unless I have missed something).

I have left the RabbitMq processing flow intact but with the expectation that a future change will provide tracking or some other safety net for the above scenario. Do you have a better option/insight into the RabbitMQ model?

Other transports
A NotSupportedException will be thrown if IConsumerErrorHandler returns with an Abandon state.

Application headers
With ASB currently being the major benefactor to this change, it becomes a bit of a moot point. ASB does not support header customisation when dead lettering a message (DeadLetterReason and DeadLetterErrorDescription are both set, but that is the extent of the customization permitted).

@EtherZa EtherZa force-pushed the feature/356-dead-letter branch from e76c231 to 99c9b69 Compare January 1, 2025 06:27
@EtherZa
Copy link
Contributor Author

EtherZa commented Jan 1, 2025

@zarusz the build action has not been triggered

docs/intro.t.md Show resolved Hide resolved
@zarusz zarusz added this to the 3.0.0 milestone Jan 1, 2025
@zarusz
Copy link
Owner

zarusz commented Jan 1, 2025

Hi @EtherZa,

This implementation looks great! I’ve left a few minor comments for your review—one of them might be more appropriate for a separate PR to address as a standalone feature.

Regarding the GitHub build trigger issue, I’m not entirely sure what’s happening. Could you try force-pushing again to see if that resolves it?

Thanks for your contribution!

@EtherZa EtherZa force-pushed the feature/356-dead-letter branch from 99c9b69 to 031406e Compare January 1, 2025 14:52
@EtherZa EtherZa force-pushed the feature/356-dead-letter branch from 031406e to 2d86fd9 Compare January 1, 2025 15:04
@EtherZa
Copy link
Contributor Author

EtherZa commented Jan 1, 2025

This implementation looks great! I’ve left a few minor comments for your review—one of them might be more appropriate for a separate PR to address as a standalone feature.

Docs have been updated. Message properties are not as straight forward as it appears. I've added details to the comment above. Prob best to have it as a separate change.

Regarding the GitHub build trigger issue, I’m not entirely sure what’s happening. Could you try force-pushing again to see if that resolves it?

It's building again!

Thanks for your contribution!

It's a pleasure :)


I have added a RabbitMQ configuration option RequeueOnFailure() that will issue a Nack with requeue: true on Failure.

The default is still to Nack a message without a requeue but this can be changed by configuraing the switch per consumer. I have added a note to intro.md explicitly declaring that it is the developer's responsibility to Abandon all non-transient exceptions or face an inifinite loop with an example.

@EtherZa
Copy link
Contributor Author

EtherZa commented Jan 1, 2025

Okay, I don't quite understand the build trigger. I force pushed; it built and failed. I resolved the issue and force pushed again; but there does not appear to be a subsequent build?!

It looks like it was just delayed...

Copy link

sonarqubecloud bot commented Jan 1, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
66.0% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube Cloud

@zarusz
Copy link
Owner

zarusz commented Jan 1, 2025

@EtherZa I am happy to merge, however if possible perhaps you could increase coverage on some touched files to meet the coverage criteria?

@EtherZa
Copy link
Contributor Author

EtherZa commented Jan 1, 2025

@zarusz I'll look at what I can add, but most of the infringements are due to reformatting (remove trailing space, etc) or gates on the transports that don't support Abandon.

ie.

if (r.Result == ProcessResult.Abandon)
{
    throw new NotSupportedException("Transport does not support abandoning messages");
}

Do you want a test for each of these?

@zarusz
Copy link
Owner

zarusz commented Jan 1, 2025

Well, okay. Let's not bother.

Please give me a thumbs up if you plan no more changes and then I will merge.

@zarusz zarusz merged commit 15834b6 into zarusz:release/v3 Jan 1, 2025
3 checks passed
This was referenced Jan 1, 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