The ChangeLog of OpenCMIS 0.14 says:
Support for asynchronous operations has been added to the client library.
As a CMIS client, how to perform several downloads in parallel, or several uploads in parallel, with OpenCMIS 0.14 or above?
My goal is to finish all operations faster, thanks to multithreading. I could share a Session object between several thread manually, but if OpenCMIS has a built-in feature I would rather use it.
First, create a Session as usual.
Then, use this session to create an asynchronous session:
Then use this asyncSession as you would use a normal session object.
Mixing synchronous and asynchronous
Often you will want to perform some synchronous operations too. For instance, create a folder synchronously and then asynchronously upload files inside this folder. Because if you don't wait for the folder to be created, document upload will probably fail. Here is how to do in such cases:
Notice the
asyncSession.createDocument
construct above, it is because you can not writefolder.createDocument
as it would use the synchronous session.The futureDocumentId variable will let you get the identifier of the document when you need it, if you need it:
Only call this method if you really need it, and call it as late as possible.