-
Notifications
You must be signed in to change notification settings - Fork 260
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
[Bug] PostAsync throws an invalidCast exception with DynamoDB outbox #3112
Comments
Just to let you know, this issue also affects the MySqlOutbox |
I've spent some time digging into this. When looking at the When calling either the One fix would be to add an overload to |
So, in order to try and simplify configuration, we tried to move away from some of the repetition in the V9 interface. There was also a lot of complexity in the builder. When we built the samples to be switchable between transports and providers, some of the complexity of the V9 interface became particularly painful. To fix that we needed to make OutboxProducerMediator take some generic types. Arguably, TMessage is redundant, because it is always our Message type. I think I tried to drop it before, but hit a bumpy road. But TTransaction lets us understand what type of transaction you might be using with our Outbox. CommittableTransaction is a hack where we don't have a transaction, because you use the default in-memory box. Now, in principle, you could use CommittableTransaction to try and ensure a transaction with the In-Memory Outbox, but right now we have not really built that out. Post is our simple method for an asynchronous command or event. It really says "I am not using an Outbox". Of course, you are, because you use are in-memory one, but that is an implementation detail for us. So what Post was intending to do was always use the InMemory Outbox. In principle you can also use our DepositPost and ClearOutbox explicitly without a transaction provider, again the assumption being that you want to use in-memory. Now, I suspect what we have not thought about is: what happens if you set up an Outbox, but then use Post. In that design, our option that Post should always force you to an In-Memory Outbox, and passing a null transaction provider to that. The problem is that this line
is going to try to pick up the parameterized type and try to cast the mediator, but you are using the in-memory, not the persisted store version, and as the mediator is a singleton, its going to fail. In that case, I guess the best option would be to force your Post onto the registered Outbox, which would mean add a version of Post that takes an In that case, I suspect we need to ensure that if you call Post without a transactionProvider, we ensure that you don't have a different Outbox type configured, and throw a |
Thanks Ian, that clarifies the difference between Given that Instead, I feel the user journey for
I think this is achievable by:
|
Hi @dhickie. That makes sense as an algorithm. And I agree we can use the CallDepositPostAsync trick to avoid the cast. Look forward to the PR |
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:
Call PostAsync method
The failure occurs in CommandProcessor:
![image](https://private-user-images.githubusercontent.com/22519624/332784343-7e1119bf-64fd-4492-ba58-c12861c7ba16.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3Mzk1OTQsIm5iZiI6MTczOTczOTI5NCwicGF0aCI6Ii8yMjUxOTYyNC8zMzI3ODQzNDMtN2UxMTE5YmYtNjRmZC00NDkyLWJhNTgtYzEyODYxYzdiYTE2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDIwNTQ1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNjNmI5MWIzYjNlZWFkNmYwMWUyNmEyNzdhMWMwMzQ5NzkxMWI0MGU3MzkyN2M1N2QyNmI3NGZmY2JkNTVlYjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.hJymV6n4HeTIN8bj_6fc-RUL94Bltv_oZMSyPsLW_0I)
Link to original discussion: #3091
Exceptions (if any)
Further technical details
The text was updated successfully, but these errors were encountered: