IceGrid + IceBox + IceStorm - service as a publisher/subscriber

in Help Center
Hi!
I'm new to Ice so I run through a couple of tutorials and basically now I want to create a sample app. Services will be replicated and available under some name, lets say "Hello". Now the client connects to one of the instances via locator and name "Hello" and sends some request. This "query" is then replicated to the rest of the instances (so the state of all instances will be similiar). I came up with this idea:
* Service runs under IceBox
* Service registers adapter, fetches proxy and subscribes it to a topic
* after servant receives query from the client it sends some message to the specified topic.
However several problems occur. First - service needs to be available under well known name and when I try to register sever instances of the same service to a given topic - exception is thrown (AlreadyRegistered).
Second - when the service stops (stop() method) I try to deregister subscriber from the topic but the IceStorm service is down (or so assume cause - Ice.NoEndpointException proxy = "IceStorm/topic.HelloService-topic -t @ IceStorm-1.IceStorm.IceStorm.TopicManager")
Third - I assume there will be problems with service start order - what if IceStorm will start later than HelloService etc).
I'm new to Ice so I run through a couple of tutorials and basically now I want to create a sample app. Services will be replicated and available under some name, lets say "Hello". Now the client connects to one of the instances via locator and name "Hello" and sends some request. This "query" is then replicated to the rest of the instances (so the state of all instances will be similiar). I came up with this idea:
* Service runs under IceBox
* Service registers adapter, fetches proxy and subscribes it to a topic
* after servant receives query from the client it sends some message to the specified topic.
However several problems occur. First - service needs to be available under well known name and when I try to register sever instances of the same service to a given topic - exception is thrown (AlreadyRegistered).
Second - when the service stops (stop() method) I try to deregister subscriber from the topic but the IceStorm service is down (or so assume cause - Ice.NoEndpointException proxy = "IceStorm/topic.HelloService-topic -t @ IceStorm-1.IceStorm.IceStorm.TopicManager")
Third - I assume there will be problems with service start order - what if IceStorm will start later than HelloService etc).
0
Comments
You cannot register the same name twice. It sounds like what you want is to setup a replicated service. You can find out more information on service replication in the Ice manual. You might also want to look at cpp/demo/IceGrid/replication, and perhaps Issue 21 of Connections (http://www.zeroc.com/newsletter/issue21.pdf).
If you get a NoEndpoints exception, then, yes, the IceStorm server is down. In this case, you can likely ignore the exception.
If HelloService tries to contact IceStorm, and assuming IceStorm is managed by IceGrid, then there would be no issue as IceGrid would start IceStorm. If this is not your setup, then please provide more information.
I solved the problem with naming by registering each servant twice (once under well-known-name <Hello> and the second time with UUID). The problem was that each time client contacted one of the instances and the instance sent message to the topic, only one subscriber received it. IceStorm threw and error that the rest of the objects cannot be found. After some time I realized that those 3 services were running in replica group. When I detached them from that group suddenly all 3 were receiving message from the topic.
Now I know that I must be doing something wrong or misusing the Ice itself. But I wanted to keep those services in replica-group (for load balancing) and still make it possible for the to communicate in publish/subscribe manner. Can this be achieved?
I didn't want this exception occurring when unsibscribing from the topic, so now IceStorm lives in a separate service and I don't have to bother that IceStorm will be stopped before services will unregister - this is what I meant by "startup order" (sorry for not being clear
Please check the earlier referenced documentation for more details.
m_topic is initialized earlier and is of type TopicPrx. Adapter is replicated. When I subscribe, IceStorm confirms in logs that indeed subscribers came. But after first messages are sent, it throws exceptions that previously subscribed objects (indirect proxy) cannot be found. Locator for IceStorm is set to point to the IceGrid registry.
replaced with the code above ... still the same error.
Should I somehow register this direct proxy or keep it alive?
and now everything works as expected