Asynchronous Method Invocation

# Chapter 12 Asynchronous Method Invocation

omniORB 4.2 supports Asynchronous Method Invocation, AMI, as defined in the CORBA Messaging specification. It supports both the polling and callback models of asynchronous calls. Note that omniORB does not support the other parts of the Messaging specification such as Quality of Service, Routing and Persistent requests.

While omniORB mainly targets the 2.6 version of the CORBA specification, the AMI support follows the CORBA Messaging specification as described in the CORBA 3.1 specification, chapter 17 [OMG08]. That version of the specification is largely the same as the one in CORBA 2.6. The only significant difference is that exception replies in the callback model use a simpler interface-independent mapping.

## 12.1 Implied IDL

AMI works by defining some additional implied IDL for each interface in the real IDL. The implied IDL contains type and operation definitions that enable asynchronous calls.

As a guide to the implied IDL, there is a special ami back-end to omniidl that outputs the implied IDL for the given input IDL. For example, given the Echo example IDL:

// echo.idl interface Echo { string echoString(in string mesg); };

You can output the implied IDL using

> omniidl -bami echo.idl

That outputs the following to standard out:

// ReplyHandler for interface Echo interface AMI_EchoHandler : Messaging::ReplyHandler { void echoString(in string ami_return_val); void echoString_excep(in ::Messaging::ExceptionHolder excep_holder); }; // Poller valuetype for interface Echo abstract valuetype AMI_EchoPoller : Messaging::Poller { void echoString(in unsigned long ami_timeout, out string ami_return_val); }; // AMI implied operations for interface Echo interface Echo { void sendc_echoString(in ::AMI_EchoHandler ami_handler, in string mesg); ::AMI_EchoPoller sendp_echoString(in string mesg); };

Alternatively, you can use the -Wbdump option to output an interleaved version that shows the original IDL and the implied IDL together.

Note that the implied IDL output is for information only. You should not compile it, but rather instruct the omniidl C++ back-end to generate the corresponding C++ definitions.

## 12.2 Generating AMI stubs

To generate stub code including AMI types and operations, give the -Wbami command line option to omniidl’s cxx back-end:

> omniidl -bcxx -Wbami echo.idl

That generates the normal C++ stubs and skeletons, plus all the definitions in the implied IDL.

## 12.3 AMI examples

Example AMI clients for the Echo server can be found in src/examples/ami.