Archived
This forum has been archived. Please start a new discussion on GitHub.
Set properties inside Ice::Application
Dear all,
I try to set my property inside Ice::Application with the following code. I try to follow example code in the manual.
But the result of size is empty, meaning that MessageSizeMax is not updated.
Can you give me a clue where the error is?
I try to set my property inside Ice::Application with the following code. I try to follow example code in the manual.
class UbiOneServer : public Ice::Application { public: virtual int run(int, char*[]); }; int UbiOneServer::run(int argc, char* argv[]) { // Get the initialized property set. Ice::PropertiesPtr props = Ice::createProperties(argc, argv); props->setProperty("Ice.MessageSizeMax", "2024"); // Initialize a communicator with these properties. Ice::InitializationData id; id.properties = props; communicator() = Ice::initialize(argc, argv, id); Ice::PropertiesPtr oe = communicator()->getProperties(); string size = oe->getProperty("Ice.MessageSizeMax"); ..... communicator()->waitForShutdown(); return EXIT_SUCCESS; } int main(int argc, char* argv[]) { UbiOneServer app; return app.main(argc, argv, "config.server"); }
But the result of size is empty, meaning that MessageSizeMax is not updated.
Can you give me a clue where the error is?
0
Comments
-
The communicator is already initialized by the time the run method has been called -- you cannot reset the already created communicator in the run() method as you are attempting to do. Instead you must set the properties before calling Application::main. Use something like:
int main(int argc, char* argv[]) { // Get the initialized property set. Ice::PropertiesPtr props = Ice::createProperties(argc, argv); props->load("config.server"); props->setProperty("Ice.MessageSizeMax", "2024"); // Initialize a communicator with these properties. Ice::InitializationData id; id.properties = props; UbiOneServer app; return app.main(argc, argv, id); }
0 -
Thanks,
I also put MessageSizeMax=2024 string in "config.server" and it is working too.
Widy0