protected void dispatch(Object msg, ActorRef sender, ActorRef target) { target.forward(msg, getContext()); }
private <M> void forwardToShardRegion(final M message, final Function<M, String> getId, final Function<M, String> getType, final Function<M, JsonObject> toJson, final Function<M, DittoHeaders> getDittoHeaders) { final String id = getId.apply(message); log.debug("Forwarding incoming {} to shard region of {}", message.getClass().getSimpleName(), id); final String type = getType.apply(message); final JsonObject jsonObject = toJson.apply(message); final DittoHeaders dittoHeaders = getDittoHeaders.apply(message); final ShardedMessageEnvelope messageEnvelope = ShardedMessageEnvelope.of(id, type, jsonObject, dittoHeaders); shardRegion.forward(messageEnvelope, context()); }
/** * Tries to forward the specified command to the * {@link PolicyPersistenceActor} for the Policy whose ID is * provided by the command. If no actor for that Policy ID can be found a warning is logged. * * @param command the command to be forwarded but also to provide the Policy ID for finding the associated Policy * Persistence Actor. */ void forwardToPolicyPersistenceActor(final PolicyCommand command) { PolicyPersistenceActor.getShardRegion(actorContext.system()).forward(command, actorContext); } }
/** * Tries to forward the specified command to the * {@link PolicyPersistenceActor} for the Policy whose ID is * provided by the command. If no actor for that Policy ID can be found a warning is logged. * * @param command the command to be forwarded but also to provide the Policy ID for finding the associated Policy * Persistence Actor. */ void forwardToPolicyPersistenceActor(final PolicyCommand command) { PolicyPersistenceActor.getShardRegion(actorContext.system()).forward(command, actorContext); } }
@Override public void onSuccess(Object result) throws Throwable { if (result instanceof EventReplyableMessage) { self().forward(msg, getContext()); // Allow to process reply in eventbus... } } }, getContext().dispatcher());
private void forwardCommand(final ExecuteBatch command) { final String batchId = command.getDittoHeaders() .getCorrelationId() .orElse(UUID.randomUUID().toString()); final ActorRef batchCoordinatorActor = lookupBatchCoordinatorActor(batchId); batchCoordinatorActor.forward(command, getContext()); }
private void handleExternalMessage(final OutboundSignal.WithExternalMessage mappedOutboundSignal) { getPublisherActor().ifPresent(publisher -> { incrementPublishedMessageCounter(); publisher.forward(mappedOutboundSignal, getContext()); }); }
private void handleExternalMessage(final OutboundSignal.WithExternalMessage mappedOutboundSignal) { getPublisherActor().ifPresent(publisher -> { incrementPublishedMessageCounter(); publisher.forward(mappedOutboundSignal, getContext()); }); }
@Override public void preRestart(Throwable reason, Option<Object> message) throws Exception { logger.info("Restarting PageParsingActor and resending message '{}'", message); if (message.nonEmpty()) { getSelf().forward(message.get(), getContext()); } super.preRestart(reason, message); }
@Override public void preStart() throws JMSException { final Destination destination = new JmsQueue(source); log.info("Creating AMQP Consumer for '{}'", source); if (session != null) { consumer = session.createConsumer(destination); consumer.setMessageListener((Message message) -> commandProcessor.forward(message, getContext())); } }
private void streamFailed(final Object failureMessage) { getCompletionRecipient().forward(failureMessage, getContext()); shutdown(); }
private void streamFailed(final Object failureMessage) { getCompletionRecipient().forward(failureMessage, getContext()); shutdown(); }
private void handleOutboundSignal(final OutboundSignal outbound) { final Signal<?> signal = outbound.getSource(); enhanceLogUtil(signal); log.debug("Handling outbound signal: {}", signal); mapToExternalMessage(signal) .map(message -> OutboundSignalFactory.newMappedOutboundSignal(outbound, message)) .ifPresent(outboundSignal -> publisherActor.forward(outboundSignal, getContext())); }
private void handleOutboundSignal(final OutboundSignal outbound) { final Signal<?> signal = outbound.getSource(); enhanceLogUtil(signal); log.debug("Handling outbound signal: {}", signal); mapToExternalMessage(signal) .map(message -> OutboundSignalFactory.newMappedOutboundSignal(outbound, message)) .ifPresent(outboundSignal -> publisherActor.forward(outboundSignal, getContext())); }
private void handleDittoRuntimeException(final ActorRef delegateActor, final DittoRuntimeException cre) { LogUtil.enhanceLogWithCorrelationId(logger, cre.getDittoHeaders().getCorrelationId()); logger.info("Got 'DittoRuntimeException': {} {}", cre.getClass().getName(), cre.getMessage()); cre.getDittoHeaders().getCorrelationId().ifPresent(outstandingCommandCorrelationIds::remove); if (cre.getDittoHeaders().isResponseRequired()) { delegateActor.forward(cre, getContext()); } else { logger.debug("Requester did not require response (via DittoHeader '{}') - not sending one", DittoHeaderDefinition.RESPONSE_REQUIRED); } }
private void readyTransaction(boolean returnSerialized, boolean doImmediateCommit, short clientTxVersion) { TransactionIdentifier transactionID = getTransactionID(); LOG.debug("readyTransaction : {}", transactionID); getShardActor().forward(new ForwardedReadyTransaction(transactionID, clientTxVersion, transaction, doImmediateCommit), getContext()); // The shard will handle the commit from here so we're no longer needed - self-destruct. getSelf().tell(PoisonPill.getInstance(), getSelf()); } }
@Override public Receive createReceive() { return ReceiveBuilder.create() .match(RetrieveStatisticsDetails.class, cmd -> thingsUpdaterActor.forward(cmd, getContext())) .match(Status.Failure.class, f -> log.error(f.cause(), "Got failure: {}", f)) .matchAny(m -> { log.warning("Unknown message: {}", m); unhandled(m); }) .build(); }
@Override public Receive createReceive() { return ReceiveBuilder.create() .match(RetrieveStatisticsDetails.class, cmd -> thingsUpdaterActor.forward(cmd, getContext())) .match(Status.Failure.class, f -> log.error(f.cause(), "Got failure: {}", f)) .matchAny(m -> { log.warning("Unknown message: {}", m); unhandled(m); }) .build(); }
@Override public Receive createReceive() { return ReceiveBuilder.create() .match(DevOpsCommand.class, command -> getContext().getParent().forward( new DevOpsCommandViaPubSub(command), getContext() )) .match(DistributedPubSubMediator.SubscribeAck.class, this::handleSubscribeAck) .matchAny(m -> { log.warning(UNKNOWN_MESSAGE_TEMPLATE, m); unhandled(m); }).build(); }
@Override public Receive createReceive() { return ReceiveBuilder.create() .match(DevOpsCommand.class, command -> getContext().getParent().forward( new DevOpsCommandViaPubSub(command), getContext() )) .match(SubscribeAck.class, this::handleSubscribeAck) .matchAny(m -> { log.warning(UNKNOWN_MESSAGE_TEMPLATE, m); unhandled(m); }).build(); }