on 03-24-2009 10:18 AM
Hi,
I am using MDM java API 5.5 SP 06 Patch 2. Should i need to close the connection and destroy the session every time when i create them? If yes, How can i do that.
Thanks.
Hi Jyothi,
It is very important to destroy the User/Repository session after you no longer require them because it will unnecessarily consume resources. Because automatic destruction of Sessions takes very long and is not guaranteed and it will definitely affect the system performance.
You can use the below method to destroy any type of session, be it Repository or User session.
public void destroySession(String strSessionId)
{
DestroySessionCommand objDestroySessionCommand = new DestroySessionCommand(objConnectionAccessor);
objDestroySessionCommand.setSession(strSessionId);
try
{
objDestroySessionCommand.execute();
}
catch (CommandException e)
{
e.printStackTrace();
}
}
Just pas he Session Id to the method.
Hope this helps!!
Cheers,
Arafat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jyothi,
Kindly update us...
Regards,
Jitesh Talreja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jyothi,
It is required to close the MDM session created.
Below is the sample code and it can be called from may be a finally block if you are calling from Java Web dynpro application
public void destroyMDMSession( com.sap.mdm.net.ConnectionPool connection, java.lang.String userSession )
{
DestroySessionCommand destroySessionCommand = new DestroySessionCommand(connection);
destroySessionCommand.setSession(userSession);
try {
destroySessionCommand.execute();
} catch (CommandException e) {
wdThis.wdGetAPI().getComponent().getMessageManager().raiseMessage(IMessageCreate_Comp.SYSTEM_EXCEPTION,
null,true);
logger.errorT("Error in destroyMDMSession()"+e.getLocalizedMessage());
}
}
The similar process needs to be followed when you are using UserSessionContext instead of Usersession
public void destroyMDMUserContext( com.sap.mdm.session.UserSessionContext userSessionCtx )
{
try {
SessionManager sessionManager = SessionManager.getInstance();
sessionManager.destroySession(userSessionCtx,SessionTypes.USER_SESSION_TYPE);
} catch (Exception e) {
wdThis.wdGetAPI().getComponent().getMessageManager().raiseMessage(
IMessageCreate_Comp.SYSTEM_EXCEPTION,null,false);
logger.errorT("Error in destroyMDMUserContext()"+e.getLocalizedMessage());
}
}
Hope this helps...
Hi Jyothi,
Addition to above post , if you are using SessionManager,you need to close repositorySession also along with user session.
Use below code to destory Repository session & User session.
sessionManager.destroySession(userSessionCtx,SessionTypes.REPOSITORY_SESSION_TYPE);
sessionManager.destroySession(userSessionCtx,SessionTypes.USER_SESSION_TYPE);
Cheers,
Veeru
Hi Jyothi,
It is better to destroy the connection since every application has some upper limit defined for number of simultaneous active connections. Also this affect the server performance as well.
Check the below code to destroy the session
public static void destroy(String session) throws CommandException{
DestroySessionCommand destroySessionCmd = new DestroySessionCommand(simpleConnection);
destroySessionCmd.setSession(session);
destroySessionCmd.execute();
session = null;
}
Regards,
Jitesh Talreja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jyothi,
Refer following doc ( page 6 ) to create, authenticate and destroy the sessions.
Hope it Helps.
Regards,
Neeharika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jyothi,
Refer below code for destroying the session through java API.
DestroySessionCommand destroySessionCommand = new DestroySessionCommand(connections);
destroySessionCommand.setSession(sessionId);
try
{
destroySessionCommand.execute();
}
catch (CommandException e)
{
e.printStackTrace();
}
It is necessary to delete the sessions else it would go on stacking up in MDM server connections. You can see how many connections are active on given repository through MDM console. If the connections increases it affects the speed of MDM server.
In our project we faced a wierd problem of MDM server slowdown after certain no of connections. We were accessing MDM thorough dynpro application but was not closing the session since it was in testing mode. But it resulted in stacking up those connections. We used to unload the repository to delete all those sessions.
After writing a code for destroying session this problem was resolved. So better close the sessions.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.