cancel
Showing results for 
Search instead for 
Did you mean: 

How can JCO 3 Server accept multi requests at the same time (Mutili thread)

Former Member
0 Kudos

I am using JCO 3. How the JCO Server accept multi requests at the same time (Mutili thread)?

Any sample code for that?

Thx

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member193379
Active Contributor
0 Kudos

Jacky,

I have not implemented but as per the JCO3 document, you have to create the seprate threads for each function module call.

It should work.

Thanks

Former Member
0 Kudos

This subject interests me as well... If one program is doing the client calls, then it might make sense that you see everything happening in sequence. But what if you had, say, about three clients doing remote function calls. These clients could be dispersed among completely different locations and networks, but might all three make RFCs that should all be handled by the same JCo server. What would happen?

Would the server, after taking the first call, wait until it is processed before processing the other two? Or would multiple concurrent calls to the same method be made? I've seen examples where multiple JCo servers would be instantiated to handle calls. Is that simply an advantage for parallel processing, or is it that necessity for handling multiple client connections without any client having to wait?

Former Member
0 Kudos

I found a documnet in sap taking about open mutli JCO server. However this doc is not for JCO3

http://help.sap.com/saphelp_nw04/helpdata/EN/8b/c88442a07b0e53e10000000a155106/content.htm

I try to modifly it

//=================

for (int i = 0; i < 5; i++) {

try {

server[ i ] = JCoServerFactory.getServer(SERVER_NAME);

} catch (JCoException ex) {

throw new RuntimeException("Unable to create the server " + SERVER_NAME + ", because of " + ex.getMessage(), ex);

}

JCoServerFunctionHandler stfcConnectionHandler = new StfcConnectionHandler();

DefaultServerHandlerFactory.FunctionHandlerFactory factory = new DefaultServerHandlerFactory.FunctionHandlerFactory();

factory.registerHandler("STFC_CONNECTION", stfcConnectionHandler);

server[ i ].setCallHandlerFactory(factory);

// additionally to step 1

MyThrowableListener eListener = new MyThrowableListener();

server[ i ].addServerErrorListener(eListener);

server[ i ].addServerExceptionListener(eListener);

MyStateChangedListener slistener = new MyStateChangedListener();

server[ i ].addServerStateChangedListener(slistener);

server[ i ].start();

System.out.println("The program can be stoped using <ctrl>+<c>");

}

//======================================================

However, it does not work

//===output====

Server state changed from STOPPED to STARTED on server with program id sap.id

Server state changed from STARTED to ALIVE on server with program id sap.id

The program can be stoped using <ctrl>+<c>

Exception in thread "main" com.sap.conn.jco.JCoRuntimeException: (136) JCO_ERROR_ILLEGAL_STATE: JCo server is currently running. Current server state is ALIVE

at com.sap.conn.jco.rt.DefaultServer.start(DefaultServer.java:577)

.....

//=======

Former Member
0 Kudos

Hi Jacky were you able to find a solution to this problem, if yes can you please share. I am also trying to implement something similar where JCo should be able to handle multiple requests from SAP at the same time.

I was looking into multi-threading for JCo but not quite sure about it..

Former Member
0 Kudos

Hi CD , I cannot find a solution to this problem.

Former Member
0 Kudos

You seem to be used to the JCo 2.x API and are thinking too complicated here.

With JCo 3.0 it's all much easier.

You just have to set the "jco.server.connection_count" property before starting the server.

This will open the required number of RFC connections for parallel processing. You do not have to start multiple server instances anymore.

Please have a look at the included sample program "StepByStepServer.java" shipped with JCo 3.

By the way, you now also have the possibility to regard an incoming RFC request as being stateful by calling the appropriate API in the JCoServerContext. In this case these connections will be held open additionally to the connection_count connections. This number is for stateless connections only (which is the general default since JCo 3.0).

Former Member
0 Kudos

Hi all,

there is one not that clear point for me in this topic. If 1 JCoServer instance can run with more than 1 connections, and the only thing we have to do is setting the connections count before we start the server, then how we recognize the different requests in handleRequest() method of the JCoServerFunctionHandler. According to me if we have 1 JcoServer then we have only 1 JCoServerFunctionHandler as well, or I'm wrong?

Should the application synchronize among different calls by its own or this is done by jco already somehow?

Please advise!

Former Member
0 Kudos

I don't know whether Jacky's intent is the same as mine, but I'm not looking for information on how to handle parallel connections to SAP from my Java server (I see the connection pooling available).

I'm interested in how to receive + process multiple calls in parallel within one process to support a high-volume environment.  With JCo 3, I don't see an obvious way to manage multiple JCo servers within one process.  The only alternative I've seen is to run each JCo server as separate process/instance.

Overall, I'm looking to run a process that can connect with multiple SAP instances, and send/receive + process the RFC calls in parallel.

Any insight would be very much appreciated!

former_member193379
Active Contributor
0 Kudos

Jacky,

Could you please provide more explaination, what do you mean my multiple request same time?

Thanks

Former Member
0 Kudos

I want to implement a JCO server which handle function call from SAP. But I found that the example "StepByStepServer" in the JCO3 only accept one call a time. I want the server can process mutli requests from sap at the same time.

for example the process takes 5 seconds.

it will process like that:

job1-start

job1-end

job2-start

job2-end

job3-start

job3-end

I want the server can handle the jobs at the same time (eg use 3 threads)

job1-start

job2-start

job3-start

job2-end

job1-end

job3-end

Thx

former_member193379
Active Contributor
0 Kudos