This topic has not yet been written. The content below is from the topic description.
Unlike the Client.invoke() method, InvokerCallbackHandler.handleCallback() has a void return type, so it does not provide a way of knowing if the callback has been received by the client. In fact, a void return type is appropriate since the immediate effect of a call to InvokerCallbackHandler.handleCallback() may be no more than storing the callback for later retrieval. However, it may be useful for the application to be informed when the callback has made its way to the client, and Remoting has a listener mechanism that can provide callback acknowledgements. An object that implements the org.jboss.remoting.callback.CallbackListener interface public interface CallbackListener { /** * @param callbackHandler InvokerCallbackHandler that handled this callback * @param callbackId id of callback being acknowledged * @param response either (1) response sent with acknowledgement or (2) null */ void acknowledgeCallback( InvokerCallbackHandler callbackHandler, Object callbackId, Object response); } may be registered to receive an acknowledgement for a particular callback by adding it to the callback's returnPayload map with the key org.jboss.remoting.callback.ServerInvokerCallbackHandler.CALLBACK_LISTENER (actual value "callbackListener"). It is also necessary to assign an identifier to the callback by adding some unique object, recognizable by the application, to the callback's returnPayload map with the key ServerInvokerCallbackHandler.CALLBACK_ID (actual value "callbackId"). This identifier will be passed as the callbackId parameter of the CallbackListener.acknowledgeCallback() method. There are two ways in which callbacks can be acknowledged: explicit acknowledgements, and automatic acknowledgements. Note that automatic acknowledgements are available only for push callbacks and simulated push callbacks (see Section Registering callback handlers) transmitted by the InvokerCallbackHandler.handleCallback() method. Callbacks may be acknowledged explicitly by the client side application code by calling one of the overloaded acknowledgeCallback() and acknowledgeCallbacks() methods public int acknowledgeCallback( InvokerCallbackHandler callbackHandler, Callback callback) throws Throwable; public int acknowledgeCallback( InvokerCallbackHandler callbackHandler, Callback callback, Object response) throws Throwable; public int acknowledgeCallbacks( InvokerCallbackHandler callbackHandler, List callbacks) throws Throwable; public int acknowledgeCallbacks( InvokerCallbackHandler callbackHandler, List callbacks, List responses) throws Throwable; of the Client class. In each case the callbackHandler parameter is the client side InvokerCallbackHandler which received the callback. The first two and the latter two methods acknowledge a single callback and a list of callbacks, respectively. In the latter case, each of the callbacks must have the same registered CallbackListener. The second and fourth methods also allow a response value to be associated with each callback acknowledgement, which will passed as the response parameter of the CallbackListener.acknowledgeCallback() method. For the fourth method, the lengths of the callbacks list and the responses list must be the same. It is also possible to request that Remoting automatically supply acknowledgements for push callbacks and simulated push callbacks by adding the key ServerInvokerCallbackHandler.REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS (actual value "remotingAcknowledgesPushCallbacks") to the callback's returnPayload map with the value of true, along with the ServerInvokerCallbackHandler.CALLBACK_LISTENER and ServerInvokerCallbackHandler.CALLBACK_ID entries. The acknowledgement is generated after the callback has been delivered by a call to handleCallback() on the client side InvokerCallbackHandler. For an example of code that uses callback acknowledgements, see the classes in the package org.jboss.remoting.samples.callback.acknowledgement.