Hi,
In our application, we have a lot of servlets and workflows that run on continuously. We were thinking of using sessions as we need to update the JCR.
From the servlet we can get the sessions like slingRequest.getResourceResolver.adapTo(Session.class) and in the workflow we already have a session in the method signature if the class implements WorkflowProcess or something.
Do we need to explicitly close these session or sling engine will close these session for us once we the code goes out of scope for the method.
Any help is appreciated.
Thanks.
Solved! Go to Solution.
kumarlal123 wrote...
Sham HC wrote...
kumarlal123 wrote...
justin_at_adobe wrote...
bsloki wrote...
Hi Kumar,
We need to close the session in both the scenarios which you have mentioned.
No.... closing a Session (or ResourceResolver) which your code didn't create would have significant consequences. Like Feike said - only close what you open.
Is slingRequest.getResourceResolver().adaptTo(Session.class) same as slingRepository.loginAdmin(null)?
Lastly, how many concurrent sessions can we have in Author and Publisher instances (any rough ideas?)
Both session are different. adoptTo(Session.class) is dynamic & returns the session of user. Where as loginAdmin always returns a session to the default workspace which has administrative powers.
There is no limit of concurrent sessions but if more than 100 at given point of time then some thing not properly implemented. AEM tested under heavy load with tough tool not consumed more than 43. Refer [1] to identify such issue.
[1] http://helpx.adobe.com/experience-manager/kb/AnalyzeUnclosedSessions.html
Hi Sham,
Yes, you are right that request will give use the user session and the other will give admin session. I did not phrased my question right it seems like. What i wanted to ask was that if i get a session out of request object, do i have to close it? I know it has been iterated above that i do, but i don't seem to understand why i need to close the session as it was an adaptation essentially and i was not opening a session explicitly.
Same goes with the workflow sessions as they are injected by the workflow process, why do i close it. If i am not using that session, i am not closing it but if i do why do i need to close it?
Sorry to use all caps here, but..
DO NOT CLOSE THE SESSION FROM THE REQUEST OBJECT OR THE WORKFLOW PROCESS. ONLY CLOSE A SESSION OR RESOURCERESOLVER IF YOU OPEN IT.
Only if you "create" a session you the close(logout) it.
Same for a resourceResolver, only close it if you have created it.
Hi Kumar,
We need to close the session in both the scenarios which you have mentioned.
Views
Replies
Total Likes
bsloki wrote...
Hi Kumar,
We need to close the session in both the scenarios which you have mentioned.
No.... closing a Session (or ResourceResolver) which your code didn't create would have significant consequences. Like Feike said - only close what you open.
Views
Replies
Total Likes
justin_at_adobe wrote...
bsloki wrote...
Hi Kumar,
We need to close the session in both the scenarios which you have mentioned.
No.... closing a Session (or ResourceResolver) which your code didn't create would have significant consequences. Like Feike said - only close what you open.
Hi Justin,
Is slingRequest.getResourceResolver().adaptTo(Session.class) same as slingRepository.loginAdmin(null)? The reason i am asking it is because in the first case i am getting the session out of request and engine might be clearing everything out from the request variable once the request is performed.
Same is in the case of Workflows. In workflows sessions are injected automatically and should be cleared automatically. I know if i manually create a session i need to close it.
Lastly, how many concurrent sessions can we have in Author and Publisher instances (any rough ideas?)
Thanks in advance.
Views
Replies
Total Likes
kumarlal123 wrote...
justin_at_adobe wrote...
bsloki wrote...
Hi Kumar,
We need to close the session in both the scenarios which you have mentioned.
No.... closing a Session (or ResourceResolver) which your code didn't create would have significant consequences. Like Feike said - only close what you open.
Is slingRequest.getResourceResolver().adaptTo(Session.class) same as slingRepository.loginAdmin(null)?
Lastly, how many concurrent sessions can we have in Author and Publisher instances (any rough ideas?)
Both session are different. adoptTo(Session.class) is dynamic & returns the session of user. Where as loginAdmin always returns a session to the default workspace which has administrative powers.
There is no limit of concurrent sessions but if more than 100 at given point of time then some thing not properly implemented. AEM tested under heavy load with tough tool not consumed more than 43. Refer [1] to identify such issue.
[1] http://helpx.adobe.com/experience-manager/kb/AnalyzeUnclosedSessions.html
Views
Replies
Total Likes
Sham HC wrote...
kumarlal123 wrote...
justin_at_adobe wrote...
bsloki wrote...
Hi Kumar,
We need to close the session in both the scenarios which you have mentioned.
No.... closing a Session (or ResourceResolver) which your code didn't create would have significant consequences. Like Feike said - only close what you open.
Is slingRequest.getResourceResolver().adaptTo(Session.class) same as slingRepository.loginAdmin(null)?
Lastly, how many concurrent sessions can we have in Author and Publisher instances (any rough ideas?)
Both session are different. adoptTo(Session.class) is dynamic & returns the session of user. Where as loginAdmin always returns a session to the default workspace which has administrative powers.
There is no limit of concurrent sessions but if more than 100 at given point of time then some thing not properly implemented. AEM tested under heavy load with tough tool not consumed more than 43. Refer [1] to identify such issue.
[1] http://helpx.adobe.com/experience-manager/kb/AnalyzeUnclosedSessions.html
Hi Sham,
Yes, you are right that request will give use the user session and the other will give admin session. I did not phrased my question right it seems like. What i wanted to ask was that if i get a session out of request object, do i have to close it? I know it has been iterated above that i do, but i don't seem to understand why i need to close the session as it was an adaptation essentially and i was not opening a session explicitly.
Same goes with the workflow sessions as they are injected by the workflow process, why do i close it. If i am not using that session, i am not closing it but if i do why do i need to close it?
Views
Replies
Total Likes
kumarlal123 wrote...
Sham HC wrote...
kumarlal123 wrote...
justin_at_adobe wrote...
bsloki wrote...
Hi Kumar,
We need to close the session in both the scenarios which you have mentioned.
No.... closing a Session (or ResourceResolver) which your code didn't create would have significant consequences. Like Feike said - only close what you open.
Is slingRequest.getResourceResolver().adaptTo(Session.class) same as slingRepository.loginAdmin(null)?
Lastly, how many concurrent sessions can we have in Author and Publisher instances (any rough ideas?)
Both session are different. adoptTo(Session.class) is dynamic & returns the session of user. Where as loginAdmin always returns a session to the default workspace which has administrative powers.
There is no limit of concurrent sessions but if more than 100 at given point of time then some thing not properly implemented. AEM tested under heavy load with tough tool not consumed more than 43. Refer [1] to identify such issue.
[1] http://helpx.adobe.com/experience-manager/kb/AnalyzeUnclosedSessions.html
Hi Sham,
Yes, you are right that request will give use the user session and the other will give admin session. I did not phrased my question right it seems like. What i wanted to ask was that if i get a session out of request object, do i have to close it? I know it has been iterated above that i do, but i don't seem to understand why i need to close the session as it was an adaptation essentially and i was not opening a session explicitly.
Same goes with the workflow sessions as they are injected by the workflow process, why do i close it. If i am not using that session, i am not closing it but if i do why do i need to close it?
Sorry to use all caps here, but..
DO NOT CLOSE THE SESSION FROM THE REQUEST OBJECT OR THE WORKFLOW PROCESS. ONLY CLOSE A SESSION OR RESOURCERESOLVER IF YOU OPEN IT.
kumarlal123 wrote...
Yes, you are right that request will give use the user session and the other will give admin session. I did not phrased my question right it seems like. What i wanted to ask was that if i get a session out of request object, do i have to close it?
For adaptTo example given above The session will be closed automatically by the framework
Views
Replies
Total Likes
here a good blogpost:
"Ownership: You open it — you close it."
Views
Replies
Total Likes