Home Help Center

C++ AMI with Type-Safe Callback - using a proxy inside the return callback

D. FleuryD. Fleury Member David FLEURYOrganization: ConsertoProject: GSM Capture
I have some problem using C++ AMI with type-safe methods (Ice 3.4.2 - Windows 8)

I have a service to send 500.000 referentiel datas. Too big for one request, so I use a getFromIndex query to send back to client a 1000 data block. So the client repeat the getFromIndex call until it returns a 0 size block, else increment the from index with the data block size.

In the type safe callback, since I have no access to the proxy used for the begin_...., I have add it to my callback class (and a pointer to my GUI), but when I use it, I got an exception near :
IceProxy::Shield::InstrumentQuery::begin_getInstruments(::Ice::Int fromIndex, const ::Ice::Context* __ctx, const ::IceInternal::CallbackBasePtr& __del, const ::Ice::LocalObjectPtr& __cookie)

I have done the same kind of thing with the non type-safe callback, and it's fine
(using the proxy returned by getProxy())

Does anybody see what am I doing wrong ?

Thanks for your help.

Here my code:
// ------------------------------ Run Async Callback Type-Safe ---------------------------
class GetInstrumentCBTypeSafe : public IceUtil::Shared
   FLTKPrinterClient* win;
   Shield::InstrumentQueryPrx& instrumentQuery;

   GetInstrumentCBTypeSafe(FLTKPrinterClient* w, Shield::InstrumentQueryPrx& proxy)
      : win(w), instrumentQuery(proxy) {}

   void getInstrumentCB(const Shield::Instruments& results)
      IceUtil::Mutex::Lock lock(mutex);

      if (results.size() != 0)
         InsertResultToInstruments(results, instruments);

         Shield::Callback_InstrumentQuery_getInstrumentsPtr getInstrumentCB
            = newCallback_InstrumentQuery_getInstruments(this, &GetInstrumentCBTypeSafe::getInstrumentCB, &GetInstrumentCBTypeSafe::failureCB);

         [B]instrumentQuery[/B]->begin_getInstruments(currentPosition, getInstrumentCB);
         currentPosition += results.size();
         isFinished = true;


   void failureCB(const Ice::Exception& ex)  { /* TODO */  }
typedef IceUtil::Handle<GetInstrumentCBTypeSafe> GetInstrumentCBTypeSafePtr;

This is how I initiate it :
   Shield::InstrumentQueryPrx instrumentQuery = GetInstrumentPrx();

   IceUtil::Mutex::Lock lock(mutex);

   GetInstrumentCBTypeSafePtr cb = new GetInstrumentCBTypeSafe(win, instrumentQuery);

   Shield::Callback_InstrumentQuery_getInstrumentsPtr getInstrumentCB
      = newCallback_InstrumentQuery_getInstruments(cb, &GetInstrumentCBTypeSafe::getInstrumentCB, &GetInstrumentCBTypeSafe::failureCB);

   // Starting <numRequests> calls in parallel
   for (int i = 0; i < numRequests; ++i, currentPosition += 1000)
      instrumentQuery->begin_getInstruments(currentPosition, getInstrumentCB);


  • D. FleuryD. Fleury Member David FLEURYOrganization: ConsertoProject: GSM Capture
    Ok I found my mistake, I have used a reference to the proxy instead of a copy in the callback.
    It works fine now.

    class GetInstrumentCBTypeSafe : public IceUtil::Shared
       FLTKPrinterClient* win;
       [B]Shield::InstrumentQueryPrx instrumentQuery;[/B]
       GetInstrumentCBTypeSafe(FLTKPrinterClient* w, Shield::InstrumentQueryPrx proxy)
Sign In or Register to comment.