- OnComplete<Object> onComplete = new OnComplete<Object>() {
- @Override
- public void onComplete(Throwable failure, Object reply) throws Throwable {
- if(failure != null) {
- LOG.error("FindRouters failed", failure);
- sender.tell(new akka.actor.Status.Failure(failure), self);
- return;
- }
-
- RpcRegistry.Messages.FindRoutersReply findReply =
- (RpcRegistry.Messages.FindRoutersReply)reply;
-
- List<Pair<ActorRef, Long>> actorRefList = findReply.getRouterWithUpdateTime();
-
- if(actorRefList == null || actorRefList.isEmpty()) {
- String message = String.format(
- "No remote implementation found for rpc %s", msg.getRpc());
- sender.tell(new akka.actor.Status.Failure(new RpcErrorsException(
- message, Arrays.asList(RpcResultBuilder.newError(ErrorType.RPC,
- "operation-not-supported", message)))), self);
- return;
- }
-
- finishInvokeRpc(actorRefList, msg, sender, self);
- }
- };
-
- future.onComplete(onComplete, getContext().dispatcher());
- }
-
- protected void finishInvokeRpc(final List<Pair<ActorRef, Long>> actorRefList,
- final InvokeRpc msg, final ActorRef sender, final ActorRef self) {
-
- RoutingLogic logic = new LatestEntryRoutingLogic(actorRefList);
-
- ExecuteRpc executeMsg = new ExecuteRpc(XmlUtils.inputCompositeNodeToXml(msg.getInput(),
- schemaContext), msg.getRpc());
+ try {
+ final CheckedFuture<DOMRpcResult, DOMRpcException> future = rpcService.invokeRpc(schemaPath, input);
+
+ Futures.addCallback(future, new FutureCallback<DOMRpcResult>() {
+ @Override
+ public void onSuccess(final DOMRpcResult result) {
+ if (result == null) {
+ // This shouldn't happen but the FutureCallback annotates the result param with Nullable so
+ // handle null here to avoid FindBugs warning.
+ LOG.debug("Got null DOMRpcResult - sending null response for execute rpc : {}", msg.getRpc());
+ sender.tell(new RpcResponse(null), self);
+ return;
+ }