Closed haiderali22 closed 1 year ago
@haiderali22 i will have a look at this.. (later this day) thanks for the repo:)
you can run TestTransaction(addTransactionalTest) to verify this
@haiderali22 .. hmm.. did not had the time yesterday.. will do today.
@haiderali22 .. first finding: you should not mix spring and flapdoodle property prefix .. spring will win.. if you change it to either spring or flapdoodle:
de.flapdoodle.mongodb.embedded.storage.replSetName=testing de.flapdoodle.mongodb.embedded.storage.oplogSize=10 de.flapdoodle.mongodb.embedded.version=5.0.5
.. then mongodb will not start as he states that replSetName does not work with --nojournal
@haiderali22 .. and it looks like that you may need more then just a replica set name to make it work (https://www.baeldung.com/spring-data-mongodb-transactions) .. i will try to create a working solution for this, but it is a little bit more complicated...
@haiderali22 ok.. it looks like you need a working replica set to make this work: https://stackoverflow.com/questions/50255195/how-to-configure-a-mongodb-cluster-which-supports-sessions
@michaelmosmann I tested the code by creating a docker container with following docker compose file
version: "3.8" services: mongodb: image: mongo:latest container_name: mongodb-transaction hostname: mongodb restart: on-failure environment:
The transaction part is working fine, i was using this library to see if i can write test cases with embeded database
Ah.. thanks.. I think rs.initiate() is important.. I will see if I can make this work.
@haiderali22 .. yes.. rs.initiate() did the trick..will make a new release and will tests this with your example:) .. in the next days..
@haiderali22 i made an pull request with a working solution.. as you see i am using the new beta-version of this framework .. as this kind of change is hard in the legacy code base.. i will fine tune this a little bit, improve the documentation and will make beta to the new release version..
Can you try if this solves your problem? there are very subtle tweaks.. f.i. you can not create the service instance yourself as spring has no way to intercept the method call..
@michaelmosmann thankyou working fine with suggested changes
@haiderali22 .. did a cleanup.. now even less changes needed:)
@haiderali22 .. close it it works for you:)
I was working on a sample to test transaction with mongodb and spring boot and as per the docs i have also provided the MongoTransactionManager bean and set the replica property but still not working as expected
GitHub repo link https://github.com/haiderali22/mongodb-transaction-test