asynchronous invocation doesn't work

huihui Fang ZhaohuiOrganization: Anhui University of TechnologyProject: Video Conferencing - RPC in video transcodingMember
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

  • mesmes CaliforniaMark SpruiellOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    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
  • huihui Fang ZhaohuiOrganization: Anhui University of TechnologyProject: Video Conferencing - RPC in video transcodingMember
    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.
  • mesmes CaliforniaMark SpruiellOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    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
Sign In or Register to comment.