Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The asyncSend and asyncRequest methods return a Future handle. This handle is what the caller must use later to retrieve the asynchronous response. You can do this by using the extractFutureBody method, or just use plain Java but invoke get() on the Future handle.

The Async Client API with callbacks

In addition to the Client API from above Camel provides a variation that uses callbacks when the message Exchange is done.

Method

Returns

Description

asyncCallback

Future<Exchange>

In addition a callback is passed in as a parameter using the org.apache.camel.spi.Synchronization Callback. The callback is invoked when the message exchange is done.

asyncCallbackSendBody

Future<Object>

As above but for sending body only. This is a request only messaging style so no reply is expected. Uses the InOnly exchange pattern.

asyncCallbackRequestBody

Future<Object>

As above but for sending body only. This is a Request Reply messaging style so a reply is expected. Uses the InOut exchange pattern.

These methods also returns the Future handle in case you need them. The difference is that they invokes the callback as well when the Exchange is done being routed.

The Future API

The java.util.concurrent.Future API have among others the following methods:

...