Jon:

Another technique could be to define a timeout in the server, after which the server shuts down (drops its connection to the database). Something like:
Once the server has stopped, it may still be the case that it should re-establish its services, if you keep on accepting requests. If so you would create a server object, but not establish a connection to the RDBMS. Then, when the server object receives a request, it will check whether a connection to the database is active, and if so uses it, otherwise it establishes a new connection to carry out the request, and afterwards will keep the connection open for the given timeout period.

HTH,

---rony


On 02.04.2011 16:03, Sahananda (Jon) Wolfers wrote:

I have a question, and I hope it is ok to ask it here.

It has been brought up by my struggle to move my work to 4.0, but if solved for me could benefit many people.

 

My specific problem is about managing to use rexx/sql with ooRexx 4.0 in a multithreaded environment, but it might b better if I ask the list a more general question.

 

That is, where one has to provide one’s applications with a service that continuously runs, what is the best way to set it up, use it and tear it down.  This question has become more important in 4.0, because there used to be a loophole in ooDialog that allowed one to run methods on the ‘main’ thread of a dialog.  Now that has gone, it needs to be done properly.

 

So for me, because rexx\sql needs to run on the thread that the library was loaded on, I have built a little server, I queue message objects on the server, and it performs them on the correct thread.  That all works very well.  My problem pertains to how to set it up when it is first needed, and tear it down when it is finished with.

 

I can set it up and start it running, by doing so in the CLASS INIT method.  This means that the first script that includes the server class in a ::REQUIRES directive loads the rexx\sql libraries and kicks off the server.

 

Subsequent scripts may be loaded which ‘require’ the server class, and it is there and running. 

 

However, when all the client scripts have finished and terminated, the server is still sitting there all alone running, and my interpreter instance won’t terminate.

 

Is there some mechanism by which the server can know that everything else has terminated and it is alone in the world?

 

Ancillary to that question was a question I asked on the RexxLA list, which was, if you have a process which ‘runs on’ in this fashion, is there some way to detect which method is still ‘active’ (I use the word active advisedly, as it is probably in a guarded state).