BrighterCommand / Brighter

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

[Bug] PostAsync throws an invalidCast exception with DynamoDB outbox #3112

Open romtur opened 1 month ago

romtur commented 1 month ago

Describe the bug

An InvalidCastException is thrown when calling PostAsync with a DynamoDB outbox. However, it works correctly when calling DepositPostAsync while providing an IAmADynamoDbTransactionProvider

To Reproduce

Setup a DynamoDB outbox:

brighterBuilder.UseExternalBus((configure) =>
      { 
          configure.ProducerRegistry = new KafkaProducerRegistryFactory(kafkaConfiguration, publications).Create();
          configure.Outbox = new DynamoDbOutbox(dynamoDBClient, new DynamoDbConfiguration());
          configure.TransactionProvider = typeof(DynamoDbUnitOfWork);
          configure.ConnectionProvider = typeof(DynamoDbUnitOfWork);
      });

Call PostAsync method

The failure occurs in CommandProcessor: image

Link to original discussion: https://github.com/BrighterCommand/Brighter/discussions/3091

Exceptions (if any)

System.InvalidCastException: Unable to cast object of type 'Paramore.Brighter.ExternalBusServices2[Paramore.Brighter.Message,Amazon.DynamoDBv2.Model.TransactWriteItemsRequest]' to type 'Paramore.Brighter.ExternalBusServices2[Paramore.Brighter.Message,System.Transactions.CommittableTransaction]'

Further technical details

romtur commented 2 weeks ago

Just to let you know, this issue also affects the MySqlOutbox