BrighterCommand / Brighter

A framework for building messaging apps with .NET and C#.
https://www.goparamore.io/
MIT License
2.03k stars 257 forks source link

[Bug] Using async methods to clear outbox with SNS publishers throws exceptions #3242

Closed dhickie closed 2 months ago

dhickie commented 3 months ago

Describe the bug

The SqsMessageProducer only implements the IAmAMessageProducerSync interface, meaning it can only publish messages synchronously and has no async method.

Now that we can combine producer registries when configuring external buses, this means that if any SNS publications are included, then async methods cannot be used to clear the outbox. If they are, then an InvalidOperationException exception is thrown when trying to publish a message to SNS, and no further messages are published.

In practice, this means that:

These limitations are not obvious or straight forward for a user to understand, making them an easy rake to step on.

In this instance, my suggestion would be to implement the IAmAMessageProducerAsync interface in SqsMessageProducer (in fact, it already uses the async method from the AWS SDK, so this is easy to implement), allowing async methods to be used to clear the outbox.

Further technical details

iancooper commented 2 months ago

This should be fixed