You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Finally BillingServiceImpl.userCreated is an event listener that checks that the user exists and in this case creates a Billing asociated to that user:
Most times UserDoesntExistException is launched, even though in the logs we can see (Inserting Document containing fields: [name, _class] in collection: sample-user). Given that the EventListener method failed I assumed the global transaction would be rolled back. However the user is created and stored without rolling back.
Some times the exception is not launched and the Billing is correctly saved. This should be what happened always. Why can't it always see the user created in the same transaction??
I've reference a sample project. You need a MongoDB instance with replication (to support multidocument transactions, e.g.: MongoDb Atlas). Just configure the spring.data.mongodb.uri property form application.yml inside the project.
To call the controller: curl -X POST localhost:8080/users -d '{"name": "John Doe"}' -H "content-type: application/json"
Mark Paluch Sorry, today I read in Spring Data's Github repo that issues for Spring Data had to be opened in Jira and though that this is where it belonged. I'll wait for updates in Github then. Regards!
Jose Antonio Iñigo opened DATAMONGO-2632 and commented
Base scenario:
The controller is called to create a user :
UserServiceImpl.create is a transactional method that saves the user and publishes a UserCreatedEvent:
Finally BillingServiceImpl.userCreated is an event listener that checks that the user exists and in this case creates a Billing asociated to that user:
There are the two problems I've found:
Inserting Document containing fields: [name, _class] in collection: sample-user
). Given that the EventListener method failed I assumed the global transaction would be rolled back. However the user is created and stored without rolling back.I've reference a sample project. You need a MongoDB instance with replication (to support multidocument transactions, e.g.: MongoDb Atlas). Just configure the spring.data.mongodb.uri property form application.yml inside the project.
To call the controller: curl -X POST localhost:8080/users -d '{"name": "John Doe"}' -H "content-type: application/json"
Affects: 3.0.4 (Neumann SR4)
Reference URL: https://github.com/codependent/transactional-event-sample/tree/event-listener
The text was updated successfully, but these errors were encountered: