cancel
Showing results for 
Search instead for 
Did you mean: 

Should I create a connection for every call to the Unity API or should I connect once and leave it open for the duration of the application?

Anthony_Valle
Star Contributor
Star Contributor

I have an application that will make several calls to the Unity API to fetch documents and keywords. Is it better practice to connect and disconnect for every call or should I keep a single connection alive and use it throughout the life of the application and disconnect at the end?

 

Any documentation on the topic would be appreciated as well.

1 ACCEPTED ANSWER

Tyler_Sorber
Star Collaborator
Star Collaborator

Hi Anthony

Per Hyland's best practice, a connection should remain open for the users interaction with you application.  In short, you should not connect and disconnect per document or request.

Enhancements to OnBase 16 have helped provide this functionality in some cases like Web Services, where session management like this is a little more difficult.

View answer in original post

4 REPLIES 4

Alex_French
Elite Collaborator
Elite Collaborator

Hi Anthony,

If you haven't taken it, definitely think about Hyland's API class (or push your employer to think about it).

They'll spend half a day talking about connection management, which is a good starting point even if a lot of it doesn't make sense in some technical situations and some licensing situations.  That'll be a running theme- many of the "best practices" you learn there shouldn't be applied mechanically, they should be over-ridden by judgement, experience, and your situation, but the class will be a good starting point.

The best possible answer to your question will depend on what the application your developing is, the context it runs in, maybe your licensing.  But as a starting point-

If your app is making a series of related calls over a short period of time, you definitely want to do it under one connection.  It will keep your code simpler, it will be much more efficient at runtime (creating and closing a connection takes significant time), and it may be important for licensing depending on your situation.

So- if you're doing something like running a console app that needs to find a set of documents, retrieve metadata, and make some changes, you would almost certainly want to maintain a single connection.

If you're building a web app and thinking about one user opening a page and performing a series of operations, the answer is "it depends"- you may be trading off runtime efficiency, licensing considerations, and code complexity.  You're probably going to do something that equates to "one connection per user session".

If you're building a web app and thinking about many users connecting over time, you'll probably be creating many different connections- but it still may depend a little on how you're doing licensing and other factors.

Tyler_Sorber
Star Collaborator
Star Collaborator

Hi Anthony

Per Hyland's best practice, a connection should remain open for the users interaction with you application.  In short, you should not connect and disconnect per document or request.

Enhancements to OnBase 16 have helped provide this functionality in some cases like Web Services, where session management like this is a little more difficult.

Did the 5-minute license thing change?

There is still a 5-minute hold on Concurrent Licenses that are connected. I would suggest reviewing the following blog post for further explanation on enhancements for this topic.

www.onbase.com/.../session-management-in-the-unity-api
Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.