Open ravenlost opened 2 years ago
Hi Pat, I'll see if I can compile a list of what would need to be done to support this. Thanks for the thorough analysis. I agree it would be a good feature to add to the extension if we can support this. Bear in mind that I am mainly a CF developer and really just a hack at Java. I have only maintained this repo with minor fixes but I'm pretty familiar with the code at this point. Hopefully we can make it happen.
@sjdaniels what ever you can do is super appreciated. One thing also worth mentioning though is that if ever such a change should be brought to the extension, might as well try to update the java driver to most recent (4.4.1) as to properly support newest Mongo Server.
As per Mongo's transaction documentation: ...Use the MongoDB driver updated for the version of your MongoDB deployment....
See compatibility sheet: https://docs.mongodb.com/drivers/java/sync/current/compatibility/
So, theoretically, if one wants to use Mongo Server 5.x, they really should be using the java driver 4.4... Maybe it would still work with older driver, but might not be a good idea... Just food for thought ;)
Anyhow, thanks a million for your time with all this, even for just reading out the issue/recommandation!! Let me know if I can be of any help (testing, etc), even if I'm just learning it all right now ;)
UPDATE: just a quick note regarding transactions in Mongo, because I searched quite a bit for this one - Transactions will not work with standalone servers! You absolutely need to convert standalone servers to a replicaset (even if he's alone!) in order to have transactions work.
Refs.: https://www.mongodb.com/community/forums/t/why-replica-set-is-mandatory-for-transactions-in-mongodb/9533 https://docs.mongodb.com/manual/tutorial/convert-standalone-to-replica-set/
Cheers! Pat
Hello,
This would be more of an enhancement suggestion, but thought it be worth documenting here (not sure where else?)
It seems that the current version of the extension doesn't allow to use transactions. From my readings we need to attach the session to all operations (inserts, updates, etc.), by passing the session as an argument to operation functions: insertOne, etc.
I am really not sure, but I think this is due to the fact that the extension uses getDB(), which is now deprecated instead of getDatabase().
The latter's getCollection() function seems to return a MongoCollection<Document> object (as opposed to a DBCollection), which in turn, has the operation methods that can receive the client's session (insertOne, etc)...
Now, I am not 100% sure of all this. I am no wiz in neither Mongo, CFML or Java.... But, looking at the issue with a colleague of mine, this is somewhat what we've came up with.
I wish I could just quickly modify the extension for this, but not sure if I'm up to the challenge... yet. lol.
p.s.: here's a code snippet of how I tried to do a basic transaction using the extension (at least, how I thought it should of worked):
Thanks a million for reading this.
Cheers, Pat