/** * Gets the callbacks for specified callback handler. The handler is required because an id is * generated for each handler. So if have two callback handlers registered with the same server, * no other way to know for which handler to get the callbacks for. */ public List getCallbacks(InvokerCallbackHandler callbackHandler) throws Throwable { return getCallbacks(callbackHandler, null); }
List callbacks = client.getCallbacks(callbackHandler, metadata); if (log.isTraceEnabled()) log.trace(this + " callback count: " + (callbacks == null ? 0 : callbacks.size()));
/** * Shows how to register for pull callbacks and then get any callbacks * that are waiting on the server. * * @throws Throwable */ public void testPullCallback() throws Throwable { // our impplementation of the InvokerCallbackHandler interface, which // is defined as an inner class below. CallbackHandler callbackHandler = new CallbackHandler(); // by passing only the callback handler, will indicate pull callbacks remotingClient.addListener(callbackHandler); // the callback server generates callback messages on its own and need // to give a few seconds to generate them. Thread.currentThread().sleep(2000); // call also make regular invocations on the server at any time. makeInvocation(); // go get our callbacks residing on the server List callbacks = remotingClient.getCallbacks(callbackHandler); Iterator itr = callbacks.iterator(); while(itr.hasNext()) { Callback callbackObject = (Callback) itr.next(); System.out.println("Pull Callback value = " + callbackObject.getCallbackObject()); } // remove callback handler from server remotingClient.removeListener(callbackHandler); }
List callbacks = client.getCallbacks(callbackHandler);