How to share resources among Csp Process?

Primary tabs

I want to call some Java Remote Call through Java gateway.  The call code as following:

class CallRemote Extends %CSP.REST {

Method Index() as %Status {

Try

      set gw = createJavaGateway()

     Do callJavaMethod(gw)

     do gw.%Disconnect()

Catch {

}

}

}

But Every call need connect to Java Gateway and disconnect it. But It's cost too high( about 80ms)

So, According to my Java experences, I need create some connection and put it into global static ConnectionPool

But I don't known how to reach that using ensemble.

 

Replies

What you see could be explained best by "model mismatch"
Java Gateway connection stays as long as the connecting process exists.
While CSP.REST services a  request and stops.
To avoid repeated connection times you may run some background process as worker jobs that open Java Gateway
and get its requests from your CSP.Rest.
As you have Ensemble already, you might run your Java Gateway as a Business Service connecting OnInit() an stay connected.
This is of course all asynchronous processing which affects your response time.

If you revert it and a Java process is scanning request using Native API for Java I wouldn't expect more attractive timing.