Results 1 to 3 of 3

Thread: Can't throw CollocationOptimizationException

  1. #1
    hui
    hui is offline Registered User
    Name: Fang Zhaohui
    Organization: Anhui University of Technology
    Project: Video Conferencing - RPC in video transcoding
    Join Date
    Sep 2011
    Posts
    11

    Can't throw CollocationOptimizationException

    Hi!

    When I invoke an AMI operation using a proxy that is configured to use collocation optionzation and the servant is collocated, but Ice run time doesn't raises CollocationOptimizationException and the invocatkon doesn't work.
    I saw that CollocationOptimizationException would be raised in this case in Ice manual.

    My code:
    Code:
         ... ...
         while (true) {
              try {
                  prx->begin_sayHello ();
                  std::cout << "success asyn invoke- ";
                  break;
              } catch (const Ice::CollocationOptimizationException &) {
                  prx = prx->ice_collocationOptimized(false);
                  std::cout << "Failed asyn invoke, off collocation optimized." << std::endl;
              }
          }
          ... ...
    The servant whose object adapter was created by the same communicator as the proxy.
    But invocation begin_sayHello doesn't work ("success asyn invoke- " is outputted) and no Ice::CollocationOptimizationException is rasied.

    There is another code I modified, It works well, I catch CollocationOptimizationException and the invocation begin_sayHello does work.
    Code:
         ... ...
         try {
             prx = ice_getConnection ();
         } catch (const Ice::CollocationOptimizationException &) {
             prx = prx-ice_collocationOptimized(false);
             std::cout << "catch Ice CollocationOptimizationException." << std::endl;
         }
    
         prx->begin_sayHello ();
         ... ...
    I'm confused why the first doesn't work!

    Here is my whole test code.
    My os is Red Hat Enterprise Linux Server release 5.
    Attached Files Attached Files

  2. #2
    mes's Avatar
    mes
    mes is online now ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,445
    Hi,

    Thank you for posting a sample project.

    The exception behavior for asynchronous invocations is different than the behavior for synchronous invocations. As described in the manual, the only exception that is raised by a begin_ method is CommunicatorDestroyedException. All other exceptions are raised by the end_ method.

    The ice_getConnection method is a synchronous invocation and therefore CollocationOptimizationException is raised directly to the calling thread.

    In summary, you should receive a CollocationOptimizationException if you call end_sayHello or register an asynchronous callback.

    Regards,
    Mark

  3. #3
    hui
    hui is offline Registered User
    Name: Fang Zhaohui
    Organization: Anhui University of Technology
    Project: Video Conferencing - RPC in video transcoding
    Join Date
    Sep 2011
    Posts
    11
    I got it! Thanks very much!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 11-18-2008, 09:06 PM
  2. Ice.Current.hashCode() can throw a NPE on null enum
    By joshmoore in forum Bug Reports
    Replies: 1
    Last Post: 08-20-2007, 03:46 AM
  3. Replies: 2
    Last Post: 01-06-2006, 05:01 PM
  4. what can Monitor::wait() throw?
    By andhow in forum Help Center
    Replies: 4
    Last Post: 02-21-2005, 08:26 AM
  5. Replies: 2
    Last Post: 10-09-2004, 09:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •