private void stopMessageMappingProcessorActor() { if (messageMappingProcessorActor != null) { log.debug("Stopping MessageMappingProcessorActor."); getContext().stop(messageMappingProcessorActor); messageMappingProcessorActor = null; } }
private void stopMessageMappingProcessorActor() { if (messageMappingProcessorActor != null) { log.debug("Stopping MessageMappingProcessorActor."); getContext().stop(messageMappingProcessorActor); messageMappingProcessorActor = null; } }
private void handleExternalMessage(final OutboundSignal.WithExternalMessage mappedOutboundSignal) { getPublisherActor().ifPresent(publisher -> { incrementPublishedMessageCounter(); publisher.forward(mappedOutboundSignal, getContext()); }); }
/** * Stops a child actor. * * @param name the Actor's name */ protected final void stopChildActor(final String name) { final String nameEscaped = escapeActorName(name); final Optional<ActorRef> child = getContext().findChild(nameEscaped); if (child.isPresent()) { log.debug("Stopping child actor <{}>.", nameEscaped); getContext().stop(child.get()); } else { log.debug("Cannot stop child actor <{}> because it does not exist.", nameEscaped); } }
/** * Stops a child actor. * * @param name the Actor's name */ protected final void stopChildActor(final String name) { final String nameEscaped = escapeActorName(name); final Optional<ActorRef> child = getContext().findChild(nameEscaped); if (child.isPresent()) { log.debug("Stopping child actor <{}>.", nameEscaped); getContext().stop(child.get()); } else { log.debug("Cannot stop child actor <{}> because it does not exist.", nameEscaped); } }
private void handleExternalMessage(final OutboundSignal.WithExternalMessage mappedOutboundSignal) { getPublisherActor().ifPresent(publisher -> { incrementPublishedMessageCounter(); publisher.forward(mappedOutboundSignal, getContext()); }); }
/** * Starts a child actor. * * @param name the Actor's name * @param props the Props * @return the created ActorRef */ protected final ActorRef startChildActor(final String name, final Props props) { log.debug("Starting child actor <{}>.", name); final String nameEscaped = escapeActorName(name); return getContext().actorOf(props, nameEscaped); }
/** * Stops a child actor. * * @param actor the ActorRef */ protected final void stopChildActor(final ActorRef actor) { if (actor != null) { log.debug("Stopping child actor <{}>.", actor.path()); getContext().stop(actor); } }
/** * Stops a child actor. * * @param actor the ActorRef */ protected final void stopChildActor(final ActorRef actor) { if (actor != null) { log.debug("Stopping child actor <{}>.", actor.path()); getContext().stop(actor); } }
/** * Starts a child actor. * * @param name the Actor's name * @param props the Props * @return the created ActorRef */ protected final ActorRef startChildActor(final String name, final Props props) { log.debug("Starting child actor <{}>.", name); final String nameEscaped = escapeActorName(name); return getContext().actorOf(props, nameEscaped); }
private BaseClientData setSession(final BaseClientData data, final ActorRef sender, final DittoHeaders headers) { if (!Objects.equals(sender, getSelf()) && !Objects.equals(sender, getContext().system().deadLetters())) { return data.setSessionSender(sender) .setSessionHeaders(headers); } else { return data.resetSession(); } }
private CompletionStage<Status.Status> testMessageMappingProcessor(@Nullable final MappingContext mappingContext) { try { // this one throws DittoRuntimeExceptions when the mapper could not be configured MessageMappingProcessor.of(connectionId(), mappingContext, getContext().getSystem(), log); return CompletableFuture.completedFuture(new Status.Success("mapping")); } catch (final DittoRuntimeException dre) { log.info("Got DittoRuntimeException during initialization of MessageMappingProcessor: {} {} - desc: {}", dre.getClass().getSimpleName(), dre.getMessage(), dre.getDescription().orElse("")); getSender().tell(dre, getSelf()); return CompletableFuture.completedFuture(new Status.Failure(dre)); } }
private BaseClientData setSession(final BaseClientData data, final ActorRef sender, final DittoHeaders headers) { if (!Objects.equals(sender, getSelf()) && !Objects.equals(sender, getContext().system().deadLetters())) { return data.setSessionSender(sender) .setSessionHeaders(headers); } else { return data.resetSession(); } }
private CompletionStage<Status.Status> testMessageMappingProcessor(@Nullable final MappingContext mappingContext) { try { // this one throws DittoRuntimeExceptions when the mapper could not be configured MessageMappingProcessor.of(connectionId(), mappingContext, getContext().getSystem(), log); return CompletableFuture.completedFuture(new Status.Success("mapping")); } catch (final DittoRuntimeException dre) { log.info("Got DittoRuntimeException during initialization of MessageMappingProcessor: {} {} - desc: {}", dre.getClass().getSimpleName(), dre.getMessage(), dre.getDescription().orElse("")); getSender().tell(dre, getSelf()); return CompletableFuture.completedFuture(new Status.Failure(dre)); } }
log.warning("Consumer actor child <{}> was not found in child actors <{}>", childActorLabel, StreamSupport .stream(getContext().getChildren().spliterator(), false) .map(ref -> ref.path().name()) .collect(Collectors.toList()));
private State<BaseClientState, BaseClientData> onUnknownEvent(final Object event, final BaseClientData state) { log.warning("received unknown/unsupported message {} in state {} - status: {} - sender: {}", event, stateName(), state.getConnectionStatus() + ": " + state.getConnectionStatusDetails().orElse(""), getSender()); final ActorRef sender = getSender(); if (!Objects.equals(sender, getSelf()) && !Objects.equals(sender, getContext().system().deadLetters())) { sender.tell(unhandledExceptionForSignalInState(event, stateName()), getSelf()); } return stay(); }
try { processor = MessageMappingProcessor.of(connectionId(), mappingContext, getContext().getSystem(), log); } catch (final DittoRuntimeException dre) { log.info( messageMappingProcessorActor = getContext().actorOf(new RoundRobinPool(1) .withDispatcher("message-mapping-processor-dispatcher") .withResizer(resizer)
private State<BaseClientState, BaseClientData> onUnknownEvent(final Object event, final BaseClientData state) { Object message = event; if (event instanceof Failure) { message = ((Failure) event).cause(); } if (event instanceof Status.Failure) { message = ((Status.Failure) event).cause(); } if (message instanceof Throwable) { log.error((Throwable) message, "received Exception {} in state {} - status: {} - sender: {}", message, stateName(), state.getConnectionStatus() + ": " + state.getConnectionStatusDetails().orElse(""), getSender()); } else { log.warning("received unknown/unsupported message {} in state {} - status: {} - sender: {}", message, stateName(), state.getConnectionStatus() + ": " + state.getConnectionStatusDetails().orElse(""), getSender()); } final ActorRef sender = getSender(); if (!Objects.equals(sender, getSelf()) && !Objects.equals(sender, getContext().system().deadLetters())) { sender.tell(unhandledExceptionForSignalInState(event, stateName()), getSelf()); } return stay(); }
protected BaseClientActor(final Connection connection, final ConnectionStatus desiredConnectionStatus, final ActorRef conciergeForwarder) { checkNotNull(connection, "connection"); final Config config = getContext().getSystem().settings().config(); final java.time.Duration javaInitTimeout = config.getDuration(ConfigKeys.Client.INIT_TIMEOUT); this.conciergeForwarder = conciergeForwarder; final BaseClientData startingData = new BaseClientData(connection.getId(), connection, ConnectionStatus.UNKNOWN, desiredConnectionStatus, "initialized", Instant.now(), null, null); final FiniteDuration initTimeout = Duration.create(javaInitTimeout.toMillis(), TimeUnit.MILLISECONDS); final FiniteDuration connectingTimeout = Duration.create(CONNECTING_TIMEOUT, TimeUnit.SECONDS); startWith(UNKNOWN, startingData, initTimeout); // stable states when(UNKNOWN, inUnknownState()); when(CONNECTED, inConnectedState()); when(DISCONNECTED, inDisconnectedState()); // volatile states that time out when(CONNECTING, connectingTimeout, inConnectingState()); when(DISCONNECTING, connectingTimeout, inDisconnectingState()); when(TESTING, connectingTimeout, inTestingState()); onTransition(this::onTransition); whenUnhandled(inAnyState().anyEvent(this::onUnknownEvent)); initialize(); }
protected BaseClientActor(final Connection connection, final ConnectionStatus desiredConnectionStatus, final ActorRef conciergeForwarder) { checkNotNull(connection, "connection"); final Config config = getContext().getSystem().settings().config(); final java.time.Duration javaInitTimeout = config.getDuration(ConfigKeys.Client.INIT_TIMEOUT); this.conciergeForwarder = conciergeForwarder; final BaseClientData startingData = new BaseClientData(connection.getId(), connection, ConnectionStatus.UNKNOWN, desiredConnectionStatus, "initialized", Instant.now(), null, null); final FiniteDuration initTimeout = Duration.create(javaInitTimeout.toMillis(), TimeUnit.MILLISECONDS); final FiniteDuration connectingTimeout = Duration.create(CONNECTING_TIMEOUT, TimeUnit.SECONDS); startWith(UNKNOWN, startingData, initTimeout); // stable states when(UNKNOWN, inUnknownState()); when(CONNECTED, inConnectedState()); when(DISCONNECTED, inDisconnectedState()); // volatile states that time out when(CONNECTING, connectingTimeout, inConnectingState()); when(DISCONNECTING, connectingTimeout, inDisconnectingState()); when(TESTING, connectingTimeout, inTestingState()); onTransition(this::onTransition); whenUnhandled(inAnyState().anyEvent(this::onUnknownEvent)); initialize(); }