- // Pass the ready Futures from the previous Tx.
- ChainedTransactionProxy txProxy = new ChainedTransactionProxy(actorContext, type,
- transactionChainId, localState.getPreviousReadyFutures());
+ LOG.debug("Waiting for ready futures for on chain {}", getTransactionChainId());
+
+ // Add a callback for completion of the combined Futures.
+ final Promise<PrimaryShardInfo> returnPromise = akka.dispatch.Futures.promise();
+
+ final OnComplete onComplete = new OnComplete() {
+ @Override
+ public void onComplete(final Throwable failure, final Object notUsed) {
+ if (failure != null) {
+ // A Ready Future failed so fail the returned Promise.
+ returnPromise.failure(failure);
+ } else {
+ LOG.debug("Previous Tx readied - proceeding to FindPrimaryShard on chain {}",
+ getTransactionChainId());
+
+ // Send the FindPrimaryShard message and use the resulting Future to complete the
+ // returned Promise.
+ returnPromise.completeWith(parent.findPrimaryShard(shardName));
+ }
+ }
+ };
+
+ previous.onComplete(onComplete, getActorContext().getClientDispatcher());
+ return returnPromise.future();
+ }