- ActorContext.ASK_DURATION);
-
- if (result != null) {
- RegisterChangeListenerReply reply = (RegisterChangeListenerReply) result;
- return new DataChangeListenerRegistrationProxy(actorContext
- .actorSelection(reply.getListenerRegistrationPath()), listener,
- dataChangeListenerActor);
+ new Timeout(actorContext.getOperationDuration().$times(
+ REGISTER_DATA_CHANGE_LISTENER_TIMEOUT_FACTOR)));
+
+ if (future != null) {
+ final DataChangeListenerRegistrationProxy listenerRegistrationProxy =
+ new DataChangeListenerRegistrationProxy(listener, dataChangeListenerActor);
+
+ future.onComplete(new OnComplete(){
+
+ @Override public void onComplete(Throwable failure, Object result)
+ throws Throwable {
+ if(failure != null){
+ LOG.error("Failed to register listener at path " + path.toString(), failure);
+ return;
+ }
+ RegisterChangeListenerReply reply = (RegisterChangeListenerReply) result;
+ listenerRegistrationProxy.setListenerRegistrationActor(actorContext
+ .actorSelection(reply.getListenerRegistrationPath()));
+ }
+ }, actorContext.getActorSystem().dispatcher());
+ return listenerRegistrationProxy;