cancel
Showing results for 
Search instead for 
Did you mean: 

Problems in closing the connection

former_member1191927
Participant
0 Kudos

Hi all,

I have a public DC in which I have a generic method which creates a connection and returns the JCO.Client object to the other DCs which use this DC. The code for this is given below :-

public com.sap.mw.jco.JCO.Client getClient( )

{

//@@begin getClient()

IWDJCOClientConnection connection =

WDSystemLandscape.getJCOClientConnection(

"PROD_MODELDATA_RFC",

"");

connection.update(

connection.getMaxPoolSize(),

connection.getMaxNumberOfConnections(),

connection.getMaxWaitTime(),

connection.getConnectionTimeOut(),

connection.getMessageServer(),

connection.getSystemName(),

connection.getLogonGroup(),

connection.getClientName(),

WDUserDefinitionType.DEFINED_USER,

"userid",

"pwd",

connection.getSNCMode(),

connection.getSNCSecurityLevel(),

connection.getSNCPartnerName(),

connection.getSNCName(),

connection.getSNCLibraryPath(),

connection.getLanguage());

client = connection.getClient();

return client;

//@@end

}

Note that "PROD_METADATA_RFC" is a JCO created in content admin.I am doing this, as I will get the user id and password dynamically.

Now the code of the application which calls this DC :-

JCO.Client client = wdThis.wdGetInterfaceManagerInterface().getClient();

if (client != null) {

GetOrgDetModal model =

(GetOrgDetModal) WDModelFactory.getModelInstance(

GetOrgDetModal.class,

WDModelScopeType.TASK_SCOPE);

model.setJcoClient(client);

wdContext.nodeCmpCtx_List_of_organizations().bind(input);

try {

wdContext

.currentCmpCtx_List_of_organizationsElement()

.modelObject()

.execute();

JCO.releaseClient(client);

model.disconnectIfAlive();

wdComponentAPI.getMessageManager().reportSuccess(

"Connection released");

} catch (WDDynamicRFCExecuteException e) {

wdComponentAPI.getMessageManager().reportException(

e.getMessage(),

false);

}

}else{

wdComponentAPI.getMessageManager().reportException("problem in get client - null", true);

}

But the connections are not getting closed. I am getting max connections expiry error very frequently.

Please let me know what is the problem in the code.

Regards,

Narahari

Message was edited by: Narahari Vedula

Message was edited by: Narahari Vedula

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Narahari,

In your earlier post also VS has posted this reply to you

/people/sap.user72/blog/2005/01/08/adaptive-rfc-models-in-web-dynprosome-pointers

have you checked this one already ?.

Have you also get the message "Connection released" ??

former_member1191927
Participant
0 Kudos

Hi Baskaran,

I have checked this weblog earlier. But I cannot implement most of the points mentioned in this as all the applicaitons are already developed and changing them now to follow them will be really very difficult.

This public DC is being used by all applications in our project. I have created a seperate test DC which uses this DC and called my methods in the generic DC and tested it. In the test DC -Yes, I am getting the "Connection released" message. But when all other applications start calling this method, it is not closing the connections.

I have a doubt if I need to provide a seperate method which has :-

connection.release();

and should call that method in all the other applications to ensure that the connection is also closed and not just the client.

Note:- I am creating the connection object in my generic DC and just returing the Client object. But still the connection object remains.

Please help me in finding what is exactly wrong??

Regards,

Narahari

former_member1191927
Participant
0 Kudos

Hi Baskaran,

I have made the scope of these objects as TASK_SCOPE which was the one mentioned in seciton 3 of the Web log given by VS. I have incorporated that as well. But still it doesnt work.

Please help me in this. This is really urgent.

Regards,

Narahari

Former Member
0 Kudos

Narahari,

According to the document TASK_SCOPE should make the connection to exists only for few seconds(Call time).So i am not getting the behaviour of your application.

former_member1191927
Participant
0 Kudos

Hi Baskaran,

In all the applications which use my public DC, we have removed the "modelInstance_defaultLogicalSystem" (which is a property under "Model Settings" of the Model. But we still are having "modelInstance_defaultScope" as APPLICATION_SCOPE.

i.e.,

Model Settings :-

modelInstance_defaultLogicalSystem <b><blank></b>

modelInstance_defaultScope <b>APPLICATION_SCOPE</b>

requiresCodeGeneration true

Also under "Model Class Settings" we have :-

abapName ZY_GET_LIST_OF_ORGANIZATIONS

defaultScope <b>APPLICATION_SCOPE</b>

isExecutable true

isLocal false

rfcPartType input

I am not sure what each one exactly means.

Will override the scope which I am setting at run time while connecting ??

Regards,

Narahari

Former Member
0 Kudos

Hi Narahari,

Even if your modelInstance_defaultScope is APPLICATION_SCOPE and if you have ConnectionTimeOut as zero. then it should release the client.

As far as i understand you are overriding the Model object correctly.