Archived
This forum has been archived. Please start a new discussion on GitHub.
IceBox service - start/stop
Hi,
Just wanted to get an idea of what is the recommended approach for the lifecycle of an IceBox service.
Obviously the first time start is called I need to do something like this.
_adapter = communicator->createObjectAdapter(name);
_adapter->add(servant, "servantIdentity");
_adapter->activate();
When stop is called, I do
_adapter->deactivate();
When start is called the next time, the server gets a AlreadyRegisteredException but the exception doesn't get propagated to the service.
I was stopping a service from IceGrid Admin GUI and basically unable to start it again unless I restart the ICeBoxServer.
So how is this usually handled?
Thanks
Budyanto
Just wanted to get an idea of what is the recommended approach for the lifecycle of an IceBox service.
Obviously the first time start is called I need to do something like this.
_adapter = communicator->createObjectAdapter(name);
_adapter->add(servant, "servantIdentity");
_adapter->activate();
When stop is called, I do
_adapter->deactivate();
When start is called the next time, the server gets a AlreadyRegisteredException but the exception doesn't get propagated to the service.
I was stopping a service from IceGrid Admin GUI and basically unable to start it again unless I restart the ICeBoxServer.
So how is this usually handled?
Thanks
Budyanto
0
Comments
-
The exception is caused by you creating an adapter with a name that is already in use by an existing adapter, ie the adapter created the first time start was called.
There are a couple of things you can do to fix this. First you could change your start method to not create the adapter the second time, but just reactivate it.if(!_adapter) { _adapter = ... _adapter->add(...) } _adapter->activate();
Alternatively, you could leave start as is but instead call destroy() on the adapter in stop which then allows you to later (when start is called) create a new adapter with the same name._adapter->destroy(); _adapter = 0;
0 -
Hi Dwayne,
Thanks for the response.
I actually had to do the destroy() call in the stop.
I can't just deactivate it and reactivate it in the next start call. It seems that an adapter that has been deactivated cannot be reactivated.
Thanks
Budyanto0 -
That is correct. Once you deactivate an object adapter, you cannot reactivate. You can see the Ice manual for more information; http://www.zeroc.com/doc/Ice-3.3.1/manual/Adv_server.33.4.html0