I am using contentDB API to integrate my system with content DB. In my application I have quite few methods that make some operations inside content DB. Everything works fine but slow :(. The problem is that in each of my methods I do call a method connect
Login method (session = ManagersFactory.login(credential, CDBUrl)) takes a lot of time. How can I refactor my code to make it work quickly? My application is mulithreded. Is thare a bulid in mechanism to manage sessions? Or is it possible to create a special user that will not need a lot of time to authenticate in content DB?
first of all, I don't see a disconnect in your code. This means that all connections you are establish are never closed normally, and will stay open until they expire and time out. This is bad coding style.
Second, why don't you implement your own connection pool? As more important if your application is multi-threaded. If you don't do that in your scenario, you will quickly hit the Maximum_Sessions_Per_User limit, because most of your sessions will be unused until they time out. This implies even more problems with memory management and garbage collection.
The are tons of examples and tutorials available on the Internet, how to implement a simple connection pool. A connection pool can also intelligently manage the size of the pool and make sure each connection remains valid.
Thanks for response. I have a disconnect method in my code ;). Above was just an example . I have implemented connection pool as you adviced it works much faster when pool is already created but Firrst creation of session takes a lot of time I thought that tere is some bulit in machansm that works more quickly than calling ManagersFactory.login(credential, CDBUrl). Pooling solves my problems for now :) thanks.
what exactly is "a lot of time" for you in this context? Is this around 3 seconds? Depending on your hardware and configuration, this could be normal. You could pre-create the sessions during startup of your application to avoid waiting time when the session is requested. This can be done in the background and would have no delay impact on your code.