Copyright © 2009, ZeroC, Inc. 1
A New Asynchronous Method
Invocation API for Ice for Java
Michi Henning, Chief Scientist, ZeroC, Inc.
Introduction
Ice has had an API for asynchronous method invocation (AMI) since its inception. However, that API
is quite verbose and not all that easy to use, as well as inflexible. With the release of Ice 3.4, ZeroC
introduces a new API for asynchronous method invocation that does not suffer from these problems
and provides programmers with far more choice as to how they can structure their code. The new
API is available for Java, .NET, C++, and Python.
This article provides an overview of the new Java API and explains its most important features. (As
always, you should consult the Ice Manual for complete documentation.) Companion articles
describe the corresponding new APIs for .NET, C++, and Python.
The old API is still available and it is possible to use both the new and the old API in the same
program. This allows you to gradually migrate code away from the old API without having to change
all your code at once. For new code, we strongly recommend that you use the new API. (The old API
is deprecated and will eventually be removed entirely.)
Contents
Introduction ...................................................................................................................................... 1
The Problems of the Old API .............................................................................................................. 2
The New Approach ............................................................................................................................ 3
No Need for Metadata................................................................................................................... 4
Basic Asynchronous Invocations .................................................................................................... 4
Polling and Waiting for Call Completion ......................................................................................... 5
Completion Callbacks..................................................................................................................... 7
Using a Single Callback Method for Many Operations .................................................................... 9
Passing State from the begin_ Method to the end_ Method ................................................... 10
Type-Safe Callbacks ..................................................................................................................... 11
Flow Control ................................................................................................................................ 12
Oneway Invocations .................................................................................................................... 13
Asynchronous Invocation of Operations on Ice.Object .......................................................... 13
Concurrency ................................................................................................................................ 13
Summary ......................................................................................................................................... 14