/** * Handle asynchronous {@link Callable}. This method simply executes the given {@link Callable} * in the context of the actor thread. * * @param callAsync Call async message */ private void handleCallAsync(CallAsync callAsync) { if (callAsync.getCallable() == null) { final String result = "Received a " + callAsync.getClass().getName() + " message with an empty " + "callable field. This indicates that this message has been serialized " + "prior to sending the message. The " + callAsync.getClass().getName() + " is only supported with local communication."; LOG.warn(result); getSender().tell(new Status.Failure(new Exception(result)), getSelf()); } else { try { Object result = callAsync.getCallable().call(); getSender().tell(new Status.Success(result), getSelf()); } catch (Throwable e) { getSender().tell(new Status.Failure(e), getSelf()); } } }
/** * Handle asynchronous {@link Callable}. This method simply executes the given {@link Callable} * in the context of the actor thread. * * @param callAsync Call async message */ private void handleCallAsync(CallAsync callAsync) { if (callAsync.getCallable() == null) { final String result = "Received a " + callAsync.getClass().getName() + " message with an empty " + "callable field. This indicates that this message has been serialized " + "prior to sending the message. The " + callAsync.getClass().getName() + " is only supported with local communication."; log.warn(result); getSender().tell(new Status.Failure(new AkkaRpcException(result)), getSelf()); } else { try { Object result = callAsync.getCallable().call(); getSender().tell(new Status.Success(result), getSelf()); } catch (Throwable e) { getSender().tell(new Status.Failure(e), getSelf()); } } }
/** * Handle asynchronous {@link Callable}. This method simply executes the given {@link Callable} * in the context of the actor thread. * * @param callAsync Call async message */ private void handleCallAsync(CallAsync callAsync) { if (callAsync.getCallable() == null) { final String result = "Received a " + callAsync.getClass().getName() + " message with an empty " + "callable field. This indicates that this message has been serialized " + "prior to sending the message. The " + callAsync.getClass().getName() + " is only supported with local communication."; log.warn(result); getSender().tell(new Status.Failure(new AkkaRpcException(result)), getSelf()); } else { try { Object result = callAsync.getCallable().call(); getSender().tell(new Status.Success(result), getSelf()); } catch (Throwable e) { getSender().tell(new Status.Failure(e), getSelf()); } } }
/** * Handle asynchronous {@link Callable}. This method simply executes the given {@link Callable} * in the context of the actor thread. * * @param callAsync Call async message */ private void handleCallAsync(CallAsync callAsync) { if (callAsync.getCallable() == null) { final String result = "Received a " + callAsync.getClass().getName() + " message with an empty " + "callable field. This indicates that this message has been serialized " + "prior to sending the message. The " + callAsync.getClass().getName() + " is only supported with local communication."; log.warn(result); getSender().tell(new Status.Failure(new AkkaRpcException(result)), getSelf()); } else { try { Object result = callAsync.getCallable().call(); getSender().tell(new Status.Success(result), getSelf()); } catch (Throwable e) { getSender().tell(new Status.Failure(e), getSelf()); } } }
@Override public void onReceive(final Object message) { if (message.equals(Processing.START)) { getContext().become(new Procedure<Object>() { @Override public void apply(Object msg) throws Exception { if (msg.equals(Processing.STOP)) { getContext().unbecome(); } else { handleMessage(msg); } } }); } else { LOG.info("The rpc endpoint {} has not been started yet. Discarding message {} until processing is started.", rpcEndpoint.getClass().getName(), message.getClass().getName()); if (!getSender().equals(ActorRef.noSender())) { // fail a possible future if we have a sender getSender().tell(new Status.Failure(new AkkaRpcException("Discard message, because " + "the rpc endpoint has not been started yet.")), getSelf()); } } }
/** * Send throwable to sender if the sender is specified. * * @param throwable to send to the sender */ protected void sendErrorIfSender(Throwable throwable) { if (!getSender().equals(ActorRef.noSender())) { getSender().tell(new Status.Failure(throwable), getSelf()); } }
/** * Send throwable to sender if the sender is specified. * * @param throwable to send to the sender */ protected void sendErrorIfSender(Throwable throwable) { if (!getSender().equals(ActorRef.noSender())) { getSender().tell(new Status.Failure(throwable), getSelf()); } }
RunAsync message = new RunAsync(runAsync.getRunnable(), timeToRun); getContext().system().scheduler().scheduleOnce(delay, getSelf(), message, getContext().dispatcher(), ActorRef.noSender());
/** * Send throwable to sender if the sender is specified. * * @param throwable to send to the sender */ protected void sendErrorIfSender(Throwable throwable) { if (!getSender().equals(ActorRef.noSender())) { getSender().tell(new Status.Failure(throwable), getSelf()); } }
getContext().system().scheduler().scheduleOnce(delay, getSelf(), envelopedSelfMessage, getContext().dispatcher(), ActorRef.noSender());
getContext().system().scheduler().scheduleOnce(delay, getSelf(), envelopedSelfMessage, getContext().dispatcher(), ActorRef.noSender());
getContext().system().scheduler().scheduleOnce(delay, getSelf(), envelopedSelfMessage, getContext().dispatcher(), ActorRef.noSender());
private void handleHandshakeMessage(RemoteHandshakeMessage handshakeMessage) { if (!isCompatibleVersion(handshakeMessage.getVersion())) { sendErrorIfSender(new AkkaHandshakeException( String.format( "Version mismatch between source (%s) and target (%s) rpc component. Please verify that all components have the same version.", handshakeMessage.getVersion(), getVersion()))); } else if (!isGatewaySupported(handshakeMessage.getRpcGateway())) { sendErrorIfSender(new AkkaHandshakeException( String.format( "The rpc endpoint does not support the gateway %s.", handshakeMessage.getRpcGateway().getSimpleName()))); } else { getSender().tell(new Status.Success(HandshakeSuccessMessage.INSTANCE), getSelf()); } }
getSender().tell(new Status.Failure(rpcException), getSelf()); } catch (IOException e) { log.error("Could not deserialize rpc invocation message.", e); getSender().tell(new Status.Failure(rpcException), getSelf()); } catch (final NoSuchMethodException e) { log.error("Could not find rpc method for rpc invocation.", e); getSender().tell(new Status.Failure(rpcException), getSelf()); getSender().tell(new Status.Failure(e.getTargetException()), getSelf()); return; } else { getSender().tell(new Status.Success(result), getSelf()); log.error("Error while executing remote procedure call {}.", rpcMethod, e); getSender().tell(new Status.Failure(e), getSelf());
getSender().tell(new Status.Failure(rpcException), getSelf()); } catch (IOException e) { log.error("Could not deserialize rpc invocation message.", e); getSender().tell(new Status.Failure(rpcException), getSelf()); } catch (final NoSuchMethodException e) { log.error("Could not find rpc method for rpc invocation.", e); getSender().tell(new Status.Failure(rpcException), getSelf()); getSender().tell(new Status.Failure(e.getTargetException()), getSelf()); return; } else { getSender().tell(new Status.Success(result), getSelf()); log.error("Error while executing remote procedure call {}.", rpcMethod, e); getSender().tell(new Status.Failure(e), getSelf());
getSender().tell(new Status.Failure(rpcException), getSelf()); } catch (IOException e) { log.error("Could not deserialize rpc invocation message.", e); getSender().tell(new Status.Failure(rpcException), getSelf()); } catch (final NoSuchMethodException e) { log.error("Could not find rpc method for rpc invocation.", e); getSender().tell(new Status.Failure(rpcException), getSelf()); getSender().tell(new Status.Failure(e.getTargetException()), getSelf()); return; } else { getSender().tell(new Status.Success(result), getSelf()); log.error("Error while executing remote procedure call {}.", rpcMethod, e); getSender().tell(new Status.Failure(e), getSelf());
private void handleHandshakeMessage(RemoteHandshakeMessage handshakeMessage) { if (!isCompatibleVersion(handshakeMessage.getVersion())) { sendErrorIfSender(new AkkaHandshakeException( String.format( "Version mismatch between source (%s) and target (%s) rpc component. Please verify that all components have the same version.", handshakeMessage.getVersion(), getVersion()))); } else if (!isGatewaySupported(handshakeMessage.getRpcGateway())) { sendErrorIfSender(new AkkaHandshakeException( String.format( "The rpc endpoint does not support the gateway %s.", handshakeMessage.getRpcGateway().getSimpleName()))); } else { getSender().tell(new Status.Success(HandshakeSuccessMessage.INSTANCE), getSelf()); } }
private void handleHandshakeMessage(RemoteHandshakeMessage handshakeMessage) { if (!isCompatibleVersion(handshakeMessage.getVersion())) { sendErrorIfSender(new AkkaHandshakeException( String.format( "Version mismatch between source (%s) and target (%s) rpc component. Please verify that all components have the same version.", handshakeMessage.getVersion(), getVersion()))); } else if (!isGatewaySupported(handshakeMessage.getRpcGateway())) { sendErrorIfSender(new AkkaHandshakeException( String.format( "The rpc endpoint does not support the gateway %s.", handshakeMessage.getRpcGateway().getSimpleName()))); } else { getSender().tell(new Status.Success(HandshakeSuccessMessage.INSTANCE), getSelf()); } }
getSender().tell(new Status.Failure(rpcException), getSelf()); } catch (IOException e) { LOG.error("Could not deserialize rpc invocation message.", e); getSender().tell(new Status.Failure(rpcException), getSelf()); } catch (final NoSuchMethodException e) { LOG.error("Could not find rpc method for rpc invocation.", e); getSender().tell(new Status.Failure(rpcException), getSelf()); getSender().tell(new Status.Failure(e.getTargetException()), getSelf()); return; getSender().tell(new Status.Success(result), getSelf()); LOG.error("Error while executing remote procedure call {}.", rpcMethod, e); getSender().tell(new Status.Failure(e), getSelf());