Brighter icon indicating copy to clipboard operation
Brighter copied to clipboard

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

Open dhickie opened this issue 1 year ago • 0 comments

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:

  • IAmACommandProcessor.ClearOutboxAsync() cannot be used
  • When configuring the outbox, the UseBulk option cannot be set to true

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

  • Brighter version: 9.9.0

dhickie avatar Aug 06 '24 11:08 dhickie