I'm looking for a way to automatically make clients connect to servers and continue normal operations in the event that:
1) The client is started earlier then the server.
2) The server is shutdown and restarted on another host while the client is calling its methods.
This way I avoid race conditions while starting the system and will be able to kill and restart both the client and the server while still continuing normal operations. I have this working by catching exceptions and reconnecting, but now I want to hide this extra complexity so that my client and server programs remain simple, look similar to this:
SERVER
--------
Ice::ObjectAdapterPtr adapter=
communicator()->createObjectAdapterWithEndpoints("Hello", "default");
Ice::ObjectPtr object = new HelloI;
HelloI::setHelloProxy(communicator(),adapter,object,"hello2");
// register to IcePack/Admin
// On default this overwrites any existing proxies with that name
adapter->activate();
communicator()->waitForShutdown();
CLIENT
--------
HelloPrx hello=HelloI::getHelloProxy(communicator(),"hello2");
// retrieve from IcePack/Admin
while(1)
{
hello->methodCall();
}
Note that the 'hello->methodCall()' is hidding the fact that it internally catches any 'Ice::ConnectionRefusedExceptions' when the server is down and will then try to reconnect using the getHelloProxy() method above with the name 'hello->ice_getIdentity().name' indefinitly.
To hide the extra complexity I'm thinking of hiding it by changing the slice2cpp, slice2java, slice2*... code generators to generate the required code.
Do you think this would be a good idea?
The problem seems standard, are there any solutions available? did others ever do anything similar?
Is there any additional documentation available on the code generators?
Thanks you for your time,
Bas Terwijn

Reply With Quote
