cancel
Showing results for 
Search instead for 
Did you mean: 

How to create only one connection per user using MDM Java API

Former Member
0 Kudos

Hi experts,

There are a lot of axamples about how to create a connection to the MDM using MDM Java API, but I found a serious issue leading to the high memory consumtion if we try to save a session (UserSessionContext) and use it in the future.

I use this code to create a connection:

UserSessionContext userSessionContext = new UserSessionContext(serverName, repositoryName, (String)null, userName);

userSessionContext.setRegionLocale(locale);
userSessionContext.setConnectionType(ConnectionTypes.LOCAL_POOL_CONNECTION); 
userSessionContext.setTrustedConnection(isTrustedConnection); 
String userSessionId = getSessionManager().createSession(userSessionContext, SessionTypes.USER_SESSION_TYPE, userPassword);

When the connection is created it is saved in the static variables. When we need to use it again we do the following:

String userSessionId = getSessionManager().getSession(userSessionContext, SessionTypes.USER_SESSION_TYPE);

The problem is that when the portal has several instances and several nodes per instance we have the number of the connections equal to the total number of the nodes.

For example, if the portal has 5 instances with 3 nodes per instance we have 15 connections per user.

Is there any way to use some standard functionality to save the only one connection? We thought about a statefull session bean, but we hope to found some standard way.

Accepted Solutions (0)

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

Timur Semenchuk wrote:

The problem is that when the portal has several instances and several nodes per instance we have the number of the connections equal to the total number of the nodes.

For example, if the portal has 5 instances with 3 nodes per instance we have 15 connections per user.

are you sure? how you get this conclusion?

Former Member
0 Kudos

Yes, I am sure.

We wrote special code writing logs when we try to initialise a connection. The developer traces allow to show the columns containing information about the instance where the code is being run and the node number. We noticed that the connection is being created every time when the code is being processed on a different node (if the code is being processed twice and more on the same node - the connection already exists and everything is ok).

Best regards,
Timur Semenchuk.

junwu
Active Contributor
0 Kudos
usually user will stick to one node. you don't have to worry about.
Former Member
0 Kudos

Unfortunatelly, it is not my case and we have thousands of users that make tens thousands connections (we have more than 20 nodes, so the multiplier is almost always 20 - we checked it).

junwu
Active Contributor
0 Kudos

user will be routed to same node, if not, it must be your server problem.

Former Member
0 Kudos

We have web dispatcher that redirects the user to some instance (it is not neccessary the same instance). So, we already have multiplier that equals to the quantity of the instances. Do you know some SAP Note saying that the user must be bounded to the same node? Where have you read it? How to configure this feature?

junwu
Active Contributor
0 Kudos
i think no configuration needed, by default it is so. called session stickiness.
first request goes to node a, the subsequent request will go there also, if not, the server has to create everything again, that is performance killer. you will routed to other node if the node a is down. that's called failover.
Former Member
0 Kudos

Thank you for the link. I read it and noticed that session-stickiness is only for statefull sessions. The web services are usally stateless and, by the way, web services can be called using some technical user. Is there any configuration allowing to pass session ID for each request?

junwu
Active Contributor
0 Kudos

can't catch you.

why ws is related here?

ws configuration is here http://help.sap.com/saphelp_nw72/helpdata/en/44/4d2bb1c6b00597e10000000a155369/frameset.htm