The asynchronous request methods are similar to the asynchronous send methods, except that the request methods force the message exchange pattern to be InOut (conforming to request/reply semantics). Hence, it is generally convenient to use an asynchronous request method, if you expect to receive a reply from the producer endpoint.
If you are only concerned with the contents of the message body in the request
and in the reply, you can use the requestBody()
methods to provide
the request message body as an argument and let the producer template take care
of inserting the body into a default exchange object.
The asyncRequestBody()
methods let you specify the target
endpoint in one of the following ways: as an endpoint URI, or as an
Endpoint
object. The return value that is retrievable from the
Future
object is the body of the reply message
(Out message body), which can be returned either as a
plain Object
or converted to a specific type, T
, using
a built-in type converter (see Asynchronous invocation).
Future<Object> asyncRequestBody( String endpointUri, Object body ); <T> Future<T> asyncRequestBody( String endpointUri, Object body, Class<T> type ); Future<Object> asyncRequestBody( Endpoint endpoint, Object body ); <T> Future<T> asyncRequestBody( Endpoint endpoint, Object body, Class<T> type );
You can try out the effect of setting a single header value using the
asyncRequestBodyAndHeader()
methods. You supply the message
body and header setting as arguments to asyncRequestBodyAndHeader()
and let the producer template take care of inserting the body and exchange
property into a default exchange object.
The asyncRequestBodyAndHeader()
methods let you specify the
target endpoint in one of the following ways: as an endpoint URI, or as an
Endpoint
object. The return value that is retrievable from the
Future
object is the body of the reply message
(Out message body), which can be returned either as a
plain Object
or converted to a specific type, T
, using
a built-in type converter (see Asynchronous invocation).
Future<Object> asyncRequestBodyAndHeader( String endpointUri, Object body, String header, Object headerValue ); <T> Future<T> asyncRequestBodyAndHeader( String endpointUri, Object body, String header, Object headerValue, Class<T> type ); Future<Object> asyncRequestBodyAndHeader( Endpoint endpoint, Object body, String header, Object headerValue ); <T> Future<T> asyncRequestBodyAndHeader( Endpoint endpoint, Object body, String header, Object headerValue, Class<T> type );
The asyncRequestBodyAndHeaders()
methods are similar to the
asyncRequestBodyAndHeader()
methods, except that instead of
supplying just a single header setting, these methods allow you to specify a
complete hash map of header settings.
Future<Object> asyncRequestBodyAndHeaders( String endpointUri, Object body, Map<String, Object> headers ); <T> Future<T> asyncRequestBodyAndHeaders( String endpointUri, Object body, Map<String, Object> headers, Class<T> type ); Future<Object> asyncRequestBodyAndHeaders( Endpoint endpoint, Object body, Map<String, Object> headers ); <T> Future<T> asyncRequestBodyAndHeaders( Endpoint endpoint, Object body, Map<String, Object> headers, Class<T> type );