Archived

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

using indirects proxies from multiple IceGrids with one single Communicator

Hello,

I had problems working with indirect proxies among multiple IceGrid when using one single Communicator in my client.
On purpose, I disabled the Ice.Default.Locator property and instead I used the ice_locator() method on each proxy received form the server :

The following pseudocode works fine on the first attempt :

communicator = Ice.initialize()

strLocator = 'IceGrid/Locator:tcp -h someHost1 -p 4061'
locatorPrx = Ice.LocatorPrx.checkedCast(communicator.stringToProxy(strLocator))
mainProxyPrx = castor.SomeProxyPrx.checkedCast(communicator.stringToProxy('SomeProxyIndentity:tcp -h someHost1 -p 5064'))
someProxyPrx = mainProxyPrx.getOtherProxy().ice_locator(locatorPrx)
someProxyPrx->performSomeAction() // works fine

but a second attempt against another server fails :

strLocator2 = 'IceGrid/Locator:tcp -h **someHost2** -p 4061'
locator2Prx = Ice.LocatorPrx.checkedCast(communicator.stringToProxy(strLocator2))
anotherMainProxyPrx = castor.SomeProxyPrx.checkedCast(communicator.stringToProxy('SomeProxyIndentity:tcp -h **someHost2** -p 5064'))
someOtherProxyPrx = anotherMainProxyPrx.getOtherProxy().ice_locator(locator2Prx)
someOtherProxyPrx->performSomeAction() // get an **ObjectNotExists** exception

unless I amend the the communicator's initialization sequence :

initData = Ice.InitializationData()
initData.properties = Ice.createProperties()
initData.properties.setProperty('Ice.Default.LocatorCacheTimeout', 0)
communicator = Ice.initialize(initData)

It's like some 'ghost' previous locator is used despite a new locator has been explicitly attached to the newly obtained proxy.

What am I missing here?

Thanks in advance for any clue!

Tagged:

Comments

  • benoit
    benoit Rennes, France

    Hi,

    You should use different identities for different IceGrid instances:

    str1Locator = 'IceGrid1/Locator:tcp -h someHost1 -p 4061'
    strLocator2 = 'IceGrid2/Locator:tcp -h **someHost2** -p 4061'
    

    If you're using the same identity, both locators will share the same internal locator cache (the locator cache caches endpoints for indirect proxies).

    It works with Ice.Default.LocatorCacheTimeout=0 because this property setting disables the locator cache.

    Cheers,
    Benoit