I have an application consisting of multiple services.
All of them are using Wolverine as framework.
Now, What I am facing is this:
- A user sends a http request ie. CreateUserRequest to Service1.
- Service 1 Creates a User entity then publishes an UserCreatedEvent(User.Id)
- Service 2 consumes UserCreatedEvent and Creates UserDetails entity with the reference to User.Id
- If all went well in Service 1 and 2 (no exceptions) , the transaction should commit.
- If anything went wrong (service 1 and 2) the transaction should rollback.
Now, the first problem I have is getting the User.Id to send to Service 2 as parameter in the message. Because the entity is only added to the EF Context and the transaction is not jet committed, it’s value is 0. (I use Identity as PK in SQL)
The second problem is how to do this distributed transaction or distributed processing using Wolverine framework? I know that it supports outbox/inbox durable messaging, and it also supports Sagas, but I would like an example where Wolverine is used for this type of scenario that requires a success on 2 or more services to commit a transaction and I can’t find it.
I even don’t know if Wolverine can be used for stuff like this.
I use the following:
.NET 8.0
ASP.NET 8.0 Web api
WolverineFx latest version
RabbitMq for messaging
EF core 8.0 as ORM
SQL server 2022
Please help.
Thanks