private Optional<ExternalMessage> mapToExternalMessage(final Signal<?> signal) { try { return processor.process(signal); } catch (final DittoRuntimeException e) { log.info("Got DittoRuntimeException during processing Signal: {} - {}", e.getMessage(), e.getDescription().orElse("")); } catch (final Exception e) { log.warning("Got unexpected exception during processing Signal: {}", e.getMessage()); } return Optional.empty(); }
private Optional<ExternalMessage> mapToExternalMessage(final Signal<?> signal) { try { return processor.process(signal); } catch (final DittoRuntimeException e) { log.info("Got DittoRuntimeException during processing Signal: {} - {}", e.getMessage(), e.getDescription().orElse("")); } catch (final Exception e) { log.warning("Got unexpected exception during processing Signal: {}", e.getMessage()); } return Optional.empty(); }
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()); } }