Archived

This forum has been archived. Please start a new discussion on GitHub.

Exception in TopicManager::create

Hi,

I have a problem with the following code in the publisher. This doesn't occur on every execution though:
IceStorm::TopicPrx topic;
try {
    topic = topicManager->retrieve(itsLoggingTopic);
} catch (const IceStorm::NoSuchTopic&) {
    topic = topicManager->create(itsLoggingTopic);
}

where it throws a
IceStorm::TopicExists
exception.

Is it possible that the "subscriber" manages to create the topic just before the exception handling gets to it?

For now I have the rather ugly second test/retrieve:
    IceStorm::TopicPrx topic;
    try {
        topic = topicManager->retrieve(itsLoggingTopic);
    } catch (const IceStorm::NoSuchTopic&) {
      try {
        topic = topicManager->create(itsLoggingTopic);
      } catch  (const IceStorm::TopicExists&) {
        topic = topicManager->retrieve(itsLoggingTopic);
      }
    }

ps I am using Ice-3.3.0

Comments