/** * Prepares an {@link ExpiringTimerBuilder} with default {@link #AMQP_ROUNDTRIP_METRIC_NAME} and tags. * @param command The command to extract tags. * @return The prepared {@link ExpiringTimerBuilder} */ public static ExpiringTimerBuilder newAmqpRoundTripTimer(final Signal<?> command) { if (command instanceof Command) { return newAmqpRoundTripTimer((Command) command); } final String metricsUri = AMQP_ROUNDTRIP_METRIC_NAME + command.getType(); return newExpiringTimer(metricsUri) .tag(TracingTags.COMMAND_TYPE, command.getType()); }
/** * Prepares an {@link ExpiringTimerBuilder} with default {@link #AMQP_ROUNDTRIP_METRIC_NAME} and tags. * @param command The command to extract tags. * @return The prepared {@link ExpiringTimerBuilder} */ public static ExpiringTimerBuilder newAmqpRoundTripTimer(final Signal<?> command) { if (command instanceof Command) { return newAmqpRoundTripTimer((Command) command); } final String metricsUri = AMQP_ROUNDTRIP_METRIC_NAME + command.getType(); return newExpiringTimer(metricsUri) .tag(TracingTags.COMMAND_TYPE, command.getType()); }
private void handle(final ExternalMessage externalMessage) { ConditionChecker.checkNotNull(externalMessage); final String correlationId = externalMessage.getHeaders().get(DittoHeaderDefinition.CORRELATION_ID.getKey()); LogUtil.enhanceLogWithCorrelationId(log, correlationId); LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId); log.debug("Handling ExternalMessage: {}", externalMessage); try { final ExternalMessage messageWithAuthSubject = placeholderSubstitution.apply(externalMessage); final Optional<InboundExternalMessage> inboundMessageOpt = processor.process(messageWithAuthSubject); inboundMessageOpt.ifPresent(inboundMessage -> { final Signal<?> signal = inboundMessage.getSignal(); enhanceLogUtil(signal); applySignalIdEnforcement.accept(messageWithAuthSubject, signal); final Signal<?> adjustedSignal = mapHeaders .andThen(mappedHeaders -> adjustHeaders.apply(messageWithAuthSubject, mappedHeaders)) .andThen(signal::setDittoHeaders) .apply(inboundMessage); startTrace(adjustedSignal); // This message is important to check if a command is accepted for a specific connection, as this // happens quite a lot this is going to the debug level. Use best with a connection-id filter. log.debug("Message successfully mapped to signal: '{}'. Passing to conciergeForwarder", adjustedSignal .getType()); conciergeForwarder.tell(adjustedSignal, getSelf()); }); } catch (final DittoRuntimeException e) { handleDittoRuntimeException(e, externalMessage.getHeaders()); } catch (final Exception e) { log.warning("Got <{}> when message was processed: <{}>", e.getClass().getSimpleName(), e.getMessage()); } }
private void handle(final ExternalMessage externalMessage) { ConditionChecker.checkNotNull(externalMessage); final String correlationId = externalMessage.getHeaders().get(DittoHeaderDefinition.CORRELATION_ID.getKey()); LogUtil.enhanceLogWithCorrelationId(log, correlationId); LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId); log.debug("Handling ExternalMessage: {}", externalMessage); try { final ExternalMessage messageWithAuthSubject = placeholderSubstitution.apply(externalMessage); final Optional<InboundExternalMessage> inboundMessageOpt = processor.process(messageWithAuthSubject); inboundMessageOpt.ifPresent(inboundMessage -> { final Signal<?> signal = inboundMessage.getSignal(); enhanceLogUtil(signal); applySignalIdEnforcement.accept(messageWithAuthSubject, signal); final Signal<?> adjustedSignal = mapHeaders .andThen(mappedHeaders -> adjustHeaders.apply(messageWithAuthSubject, mappedHeaders)) .andThen(signal::setDittoHeaders) .apply(inboundMessage); startTrace(adjustedSignal); // This message is important to check if a command is accepted for a specific connection, as this // happens quite a lot this is going to the debug level. Use best with a connection-id filter. log.debug("Message successfully mapped to signal: '{}'. Passing to conciergeForwarder", adjustedSignal .getType()); conciergeForwarder.tell(adjustedSignal, getSelf()); }); } catch (final DittoRuntimeException e) { handleDittoRuntimeException(e, externalMessage.getHeaders()); } catch (final Exception e) { log.warning("Got <{}> when message was processed: <{}>", e.getClass().getSimpleName(), e.getMessage()); } }
private void handleSignal(final Signal<?> signal) { LogUtil.enhanceLogWithCorrelationId(logger, signal); final DittoHeaders dittoHeaders = signal.getDittoHeaders(); if (connectionCorrelationId.equals(dittoHeaders.getOrigin().orElse(null))) { logger.debug("Got Signal <{}> in <{}> session, " + "but this was issued by this connection itself, not telling " + "eventAndResponsePublisher about it", signal.getType(), type); } else { // check if this session is "allowed" to receive the LiveSignal if (authorizationSubjects != null && !Collections.disjoint(dittoHeaders.getReadSubjects(), authorizationSubjects)) { if (matchesNamespaces(signal)) { if (matchesFilter(signal)) { logger.debug("Got Signal <{}> in <{}> session, " + "telling eventAndResponsePublisher about it: {}", signal.getType(), type, signal); eventAndResponsePublisher.tell(signal, getSelf()); } else { logger.debug("Signal does not match filter"); } } else { logger.debug("Signal does not match namespaces"); } } } }
private static ShardedMessageEnvelope createEnvelope(final EntityId entityId, final Signal<?> signal) { return ShardedMessageEnvelope.of( entityId.toString(), signal.getType(), signal.toJson(signal.getImplementedSchemaVersion(), FieldType.regularOrSpecial()), signal.getDittoHeaders()); } }
private void handleOutboundSignal(final OutboundSignal signal) { enhanceLogUtil(signal.getSource()); if (messageMappingProcessorActor != null) { messageMappingProcessorActor.tell(signal, getSender()); } else { log.info("Cannot handle <{}> signal as there is no MessageMappingProcessor available.", signal.getSource().getType()); } }
private void handleOutboundSignal(final OutboundSignal signal) { enhanceLogUtil(signal.getSource()); if (messageMappingProcessorActor != null) { messageMappingProcessorActor.tell(signal, getSender()); } else { log.info("Cannot handle <{}> signal as there is no MessageMappingProcessor available.", signal.getSource().getType()); } }
unresolvedPlaceholder -> log.info(UNRESOLVED_PLACEHOLDERS_MESSAGE, unresolvedPlaceholder)); log.debug("Forwarding signal <{}> to client actor with targets: {}.", signal.getType(), filteredTargets);
unresolvedPlaceholder -> log.info(UNRESOLVED_PLACEHOLDERS_MESSAGE, unresolvedPlaceholder)); log.debug("Forwarding signal <{}> to client actor with targets: {}.", signal.getType(), filteredTargets);
final String signalType = transformedSignal.getType(); if (signalId.isEmpty()) { log.info("Sending signal without ID and type <{}> to concierge-dispatcherActor", signalType);
private DittoRuntimeException unhandledExceptionForSignalInState(final Object signal, final BaseClientState state) { final DittoHeaders headers = signal instanceof WithDittoHeaders ? ((WithDittoHeaders) signal).getDittoHeaders() : DittoHeaders.empty(); switch (state) { case CONNECTING: case DISCONNECTING: return ConnectionSignalIllegalException.newBuilder(connectionId()) .operationName(state.name().toLowerCase()) .timeout(CONNECTING_TIMEOUT) .dittoHeaders(headers) .build(); default: final String signalType = signal instanceof Signal ? ((Signal) signal).getType() : "unknown"; // no need to disclose Java class of signal to clients return ConnectionSignalIllegalException.newBuilder(connectionId()) .illegalSignalForState(signalType, state.name().toLowerCase()) .dittoHeaders(headers) .build(); } }
private DittoRuntimeException unhandledExceptionForSignalInState(final Object signal, final BaseClientState state) { final DittoHeaders headers = signal instanceof WithDittoHeaders ? ((WithDittoHeaders) signal).getDittoHeaders() : DittoHeaders.empty(); switch (state) { case CONNECTING: case DISCONNECTING: return ConnectionSignalIllegalException.newBuilder(connectionId()) .operationName(state.name().toLowerCase()) .timeout(CONNECTING_TIMEOUT) .dittoHeaders(headers) .build(); default: final String signalType = signal instanceof Signal ? ((Signal) signal).getType() : "unknown"; // no need to disclose Java class of signal to clients return ConnectionSignalIllegalException.newBuilder(connectionId()) .illegalSignalForState(signalType, state.name().toLowerCase()) .dittoHeaders(headers) .build(); } }
final T replyTarget = toReplyTarget(replyToFromHeader); log().info("Publishing mapped response/error message of type <{}> to reply target <{}>", outbound.getSource().getType(), replyTarget); log().debug("Publishing mapped response/error message of type <{}> to reply target <{}>: {}", outbound.getSource().getType(), replyTarget, response); outboundSource.getType(), outbound.getTargets(), message); outbound.getTargets().forEach(target -> { log().info("Publishing mapped message of type <{}> to target address <{}>", outboundSource.getType(), target.getAddress()); try { final T publishTarget = toPublishTarget(target.getAddress());
final T replyTarget = toReplyTarget(replyToFromHeader); log().info("Publishing mapped response/error message of type <{}> to reply target <{}>", outbound.getSource().getType(), replyTarget); log().debug("Publishing mapped response/error message of type <{}> to reply target <{}>: {}", outbound.getSource().getType(), replyTarget, response); outboundSource.getType(), outbound.getTargets(), message); outbound.getTargets().forEach(target -> { log().info("Publishing mapped message of type <{}> to target address <{}>", outboundSource.getType(), target.getAddress()); try { final T publishTarget = toPublishTarget(target.getAddress());
} else { log(signal).warning("No outstanding responses receiver for CommandResponse <{}>", signal.getType()); " looked up! Answering with ThingNotAccessibleException.", signal.getType(), signal.getId()); final ThingNotAccessibleException error = ThingNotAccessibleException.newBuilder(entityId().getId())