-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Make transactions usable with raw MongoDB client / collection interfaces #27311
Comments
this will be a lot of work as the transactonal facade will need to be kepts in line with the underlying MongoDB 'raw' facilities. However, two implementations could be eaisy to create:
They may be more questions to ask so we may want to think a little more about this. |
Injection sounds cleaner to me than random static methods with magic implementations that get back into the concrete context of the running request. I'm also a bit confused why |
Not having a facade is definitely OK at the moment. It could be added later by providing other accessor methods on the repository or active record without breaking compatibility. |
/cc @evanchooly, @loicmathieu |
@languitar currently, the ClientSession is created lazilly at first use and registered inside the transaction manager. Then we reuse the existing transaction interceptors. See this draft PR: #30115 |
I'm looking forward to this feature. |
The |
Description
The transaction support for MongoDB currently only works when using Panache entities directly. Sometimes, though, it is necessary to resort to the raw operations provided by
MongoCollection
etc. Such manual operations currently run outside a potentially active transaction because the session containing this transaction is not accessible for user code. The MongoDB Java driver requires to explicitly pass this session into operations for being performed inside transactions.It would be nice if there either was a way to
MongoCollection
, orThis request is the result of #27289
Implementation ideas
From my perspective it would probably best if transaction handling based on
@Transactional
and other mechanisms was handled automatically by MongoClient, MongoDatabase and MongoCollection, potentially through a Quarkus-specific facade. The MongoDB driver provides for most operations two method signatures, one with a client session passed in via the first parameter, and one without that parameter. If an ongoing transaction was not handled automatically this would often result in client code like the following needed to handle the different signatures:The text was updated successfully, but these errors were encountered: