cancel
Showing results for 
Search instead for 
Did you mean: 

Configure timeout in SAP JCo 3

Former Member
0 Kudos

Hi,

I am using JCo 3 in standalone mode.

I would like to configure the destination to timeout if a certain period is exceeded, i.e. a socket timeout.

The usecase is if I have 2/3 remote functions which start running very slow, and a lot of calls to these, it will eventually exhaust the pool for faster-returning  connections. I would like to kill such connections.

Here is a sample stacktrace of the program hanging:

com.sap.conn.rfc.driver.CpicDriver.nativeCpic_coxread(Native Method)

  com.sap.conn.rfc.driver.CpicDriver.cpic_coxread(CpicDriver.java:601)

  com.sap.conn.rfc.driver.CpicDriver.coxread(CpicDriver.java:174)

  com.sap.conn.rfc.driver.RfcTypeDirectCpic.read(RfcTypeDirectCpic.java:43)

  com.sap.conn.rfc.engine.RfcIoOpenCntl.ab_rfcread(RfcIoOpenCntl.java:663)

  com.sap.conn.rfc.engine.RfcGetImp.rfc_readData(RfcGetImp.java:263)

  com.sap.conn.rfc.engine.RfcGetImp.rfc_getdata(RfcGetImp.java:210)

  com.sap.conn.rfc.engine.RfcGetImp.ab_rfcvalue(RfcGetImp.java:135)

  com.sap.conn.rfc.engine.RfcGet.ab_rfcget(RfcGet.java:279)

  com.sap.conn.rfc.engine.RfcRcv.ab_rfcreceive(RfcRcv.java:36)

  com.sap.conn.rfc.engine.RfcIoOpenCntl.RfcReceive(RfcIoOpenCntl.java:1983)

  com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcClient.execute(MiddlewareJavaRfc.java:2032)

  com.sap.conn.jco.rt.ClientConnection.execute(ClientConnection.java:1179)

  com.sap.conn.jco.rt.ClientConnection.execute(ClientConnection.java:1008)

  com.sap.conn.jco.rt.RfcDestination.execute(RfcDestination.java:1458)

Thanks in advance.

Regards, Dimitar

Accepted Solutions (0)

Answers (1)

Answers (1)

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Dimitar,

There is no direct way of specifying a timeout for a destination or a function module invocation. But still, it is possible to limit the execution time of function modules by limitting the life span of the session. As soon as the session is ending and JCo is recognizing this in its runtime, it will cancel all function module executions belonging to this session and is thus freeing the resources on both the ABAP system an the JCo side. For that you need a fitting implementation of JCoSessionReferenceProvider that fits to your purposes.

BTW, the hanging program is simply waiting for the response of the ABAP function module - you could als verify whether the function module code could be imporved. Last but not least, if you need to execute more function modules at the same time, you should consider to allow more in the destination configuration and increase the peak size.

Best regards,

Markus

Former Member
0 Kudos

Hello Markus,

I'd like to further explain that our application is fully stateless from the ABAP / JCo point of view. There is one single destination configured, and the function calls are always stateless and - in the case when they change something - auto - commited.

Could I still achieve my usecase via SessionReferenceProvider / JCoContext ? Could you share a code snippet?

Thanks.

Regards, Dimitar

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dimitar,

yes, it's not a question if being in a stateful or stateless context. All connections currently executing an RFC in a specific JCo session will be canceled if the registered SessionReferenceProvider returns false for that specific session ID at method SessionReferenceProvider.isSessionAlive(java.lang.String sessionId)

Please also see the JCo API JavaDoc at method JCo.setProperty(java.lang.String key, java.lang.String value) for further info regarding the properties jco.session_timeout and jco.session_timeout.check_interval.

Best regards,

Stefan

Former Member
0 Kudos

That's exactly what I needed, thank you! Will post back the results.