Archived
This forum has been archived. Please start a new discussion on GitHub.
How to use IceStorm::Service class?
Hi,
i write a simple example which is used to start IceStorm service in C++ code, but i have a problem , and i don't know how to solve it. The Ice Version is 3.2.0.
this is the my function below:
int main(int argc, char* argv[]){
Ice::ObjectAdapterPtr _topicAdapter;
Ice::ObjectAdapterPtr _publishAdapter;
IceStorm::ServicePtr ISServer;
Ice::Identity ide;
ide.name = "TopicManager";
ide.category = "DemoIceStorm";
string name = "IceStorm";
string db = "db";
Ice::CommunicatorPtr ic;
Ice::InitializationData initData;
initData.properties = Ice::createProperties();
initData.properties->load("config.IceStormServer");
ic = Ice::initialize(initData);
_topicAdapter = ic->createObjectAdapter(name+".TopicManager");
_publishAdapter = ic->createObjectAdapter(name + ".Publish");
ISServer = IceStorm::Service::create( ic, _topicAdapter, _publishAdapter, name, ide, db );
cout << "the IceBox::IceStorm Start!!!" << endl;
int i;
cin >> i;
ISServer->stop();
ic->destroy();
}
this is the config.IceStormServer below:
Ice.Override.ConnectTimeout=10000
Ice.Override.Timeout=20000
Ice.RetryIntervals=5
Ice.Trace.Protocol=1
Ice.Trace.Network=1
IceStorm.InstanceName=DemoIceStorm
IceStorm.TopicManager.Endpoints=default -p 10000
IceStorm.InstanceName=DemoIceStorm
IceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
IceStorm.Trace.TopicManager=2
IceStorm.Trace.Topic=1
IceStorm.Trace.Subscriber=1
IceStorm.Trace.Flush=1
IceStorm.Flush.Timeout=2000
The function can start successfully ,but when i used publisher.exe and subscriber.exe in Demo/IceStorm/clock to test it , it can't work. and i hope it can work as "icebox --Ice.Config=config.icebox".
This is the trace of the publisher below:
[ 03/20/08 21:02:16.487 Network: trying to establish tcp connection to 127.0.0.1
:10000 ]
[ 03/20/08 21:02:16.523 Network: tcp connection established
local address = 127.0.0.1:55521
remote address = 127.0.0.1:10000 ]
Where is my error or did I misunderstood something?
i write a simple example which is used to start IceStorm service in C++ code, but i have a problem , and i don't know how to solve it. The Ice Version is 3.2.0.
this is the my function below:
int main(int argc, char* argv[]){
Ice::ObjectAdapterPtr _topicAdapter;
Ice::ObjectAdapterPtr _publishAdapter;
IceStorm::ServicePtr ISServer;
Ice::Identity ide;
ide.name = "TopicManager";
ide.category = "DemoIceStorm";
string name = "IceStorm";
string db = "db";
Ice::CommunicatorPtr ic;
Ice::InitializationData initData;
initData.properties = Ice::createProperties();
initData.properties->load("config.IceStormServer");
ic = Ice::initialize(initData);
_topicAdapter = ic->createObjectAdapter(name+".TopicManager");
_publishAdapter = ic->createObjectAdapter(name + ".Publish");
ISServer = IceStorm::Service::create( ic, _topicAdapter, _publishAdapter, name, ide, db );
cout << "the IceBox::IceStorm Start!!!" << endl;
int i;
cin >> i;
ISServer->stop();
ic->destroy();
}
this is the config.IceStormServer below:
Ice.Override.ConnectTimeout=10000
Ice.Override.Timeout=20000
Ice.RetryIntervals=5
Ice.Trace.Protocol=1
Ice.Trace.Network=1
IceStorm.InstanceName=DemoIceStorm
IceStorm.TopicManager.Endpoints=default -p 10000
IceStorm.InstanceName=DemoIceStorm
IceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
IceStorm.Trace.TopicManager=2
IceStorm.Trace.Topic=1
IceStorm.Trace.Subscriber=1
IceStorm.Trace.Flush=1
IceStorm.Flush.Timeout=2000
The function can start successfully ,but when i used publisher.exe and subscriber.exe in Demo/IceStorm/clock to test it , it can't work. and i hope it can work as "icebox --Ice.Config=config.icebox".
This is the trace of the publisher below:
[ 03/20/08 21:02:16.487 Network: trying to establish tcp connection to 127.0.0.1
:10000 ]
[ 03/20/08 21:02:16.523 Network: tcp connection established
local address = 127.0.0.1:55521
remote address = 127.0.0.1:10000 ]
Where is my error or did I misunderstood something?
0
Comments
-
The problem most likely is caused by you not activating the object adapters.
However, note that this isn't really for external use. Why don't you want to use IceBox?0 -
it could work when i add adapter->activate.
Thank you for your help.
Icebox frequently hang up ,and i don't know why ,so i want to start it in the program, maybe i can find the key to figure it out . hehe0