corbaomniorb

How do I monitor my connection to a Naming Service?


I have an application that binds object references to multiple Naming Services. If any of these Naming Services are restarted, I'd like to be able to detect that and rebind my references to it. Right now, the only way I can think of doing it is to periodically poll the Naming Service context object with something like the following (using omniorbpy):

def check_connection(context):
    try:
        if CORBA.is_nil(context):
            return False
        if context._non_existent():
            return False
    except CORBA.Exception:
        return False
    else:
        return True

I know that _non_existent() isn't intended to be used as a "ping" operation, but I can't think of any other way to do it. It would be nice if there was a way to be notified with a callback when the connection is lost without having to constantly poll the service. Any CORBA experts out there have any ideas?

Note: The network architecture and Naming Service implementations are out of my control. So switching to a persistent Naming Service isn't an option unfortunately.


Solution

  • If you can't use a persistent Naming Service then I think your only option is to poll. But I would probably just try to rebind the reference rather than check it or call _non_existant().