cancel
Showing results for 
Search instead for 
Did you mean: 

reg: MDM connection using MDM java API

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Jyothi,

Kindly update us...

Regards,

Jitesh Talreja

Former Member
0 Kudos

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...

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hello Jyothi,

Refer following doc ( page 6 ) to create, authenticate and destroy the sessions.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70a7afe4-9e3e-2b10-de8d-b105d0b8...

Hope it Helps.

Regards,

Neeharika

Former Member
0 Kudos

Hi Jyothi,

Refer

Hope it helps.

Thanks,

Minaz

Former Member
0 Kudos

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.