Archived

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

asynchronous invocation doesn't work

Hi!

I write a service using Icebox.
In my service, I found that when proxies and servants are in the same communicator, the asynchronous invocation don't work.

There is a simple example(Just add some code on demo-icebox).
my Ice version: 3.4.2
os: RedHat 5.0
Linux kernel:2.6.18-8.el5

Attachment not found.

Comments

  • mes
    mes California
    Hi,

    This is the expected behavior: Ice does not currently support asynchronous proxy invocations on a collocated servant. You will need to disable collocation optimization on any proxy that is used for asynchronous invocations.

    Regards,
    Mark
  • mes wrote: »
    Hi,

    This is the expected behavior: Ice does not currently support asynchronous proxy invocations on a collocated servant. You will need to disable collocation optimization on any proxy that is used for asynchronous invocations.

    Regards,
    Mark

    Thanks for your early reply!
    But there is another problem.
    In my application,some is in the same, other is not. If the proxies and servants are not in the same communicator,I will use async invocations. That means I must know whether proxies and servants are the same communicator! Is there any interfaces to do this? Determine whether proxies and servants are in the same communicator.
  • mes
    mes California
    The simplest solution is to completely disable collocation optimization in clients that make asynchronous invocations. You can disable it by setting Ice.Default.CollocationOptimized=0. If you still want to take advantage of collocation optimization for synchronous invocations, you can enable it on a per-proxy basis like this:
    HelloPrx proxy = ...;
    proxy = proxy->ice_collocationOptimized(true);
    proxy->sayHello();
    

    Another solution is to leave it enabled by default and disable it individually for each proxy that you will use for asynchronous invocations:
    HelloPrx proxy = ...;
    proxy = proxy->ice_collocationOptimized(false);
    proxy->begin_sayHello();
    

    Finally, you can trap CollocationOptimizationException and try again:
    HelloPrx proxy = ...;
    while(true)
    {
        try
        {
            proxy->begin_sayHello();
            break;
        }
        catch(const Ice::CollocationOptimizationException&)
        {
            proxy = proxy->ice_collocationOptimized(false);
        }
    }
    

    Regards,
    Mark