private void handleExecutePiggyBack(final ExecutePiggybackCommand command) {
LogUtil.enhanceLogWithCorrelationId(log, command);
final JsonObject piggybackCommandJson = command.getPiggybackCommand();
final String piggybackCommandType = piggybackCommandJson.getValueOrThrow(Command.JsonFields.TYPE);
if (serviceMappingStrategy.containsKey(piggybackCommandType)) {
final Jsonifiable<?> piggybackCommand;
try {
piggybackCommand = serviceMappingStrategy.get(piggybackCommandType)
.apply(piggybackCommandJson, command.getDittoHeaders());
} catch (final DittoRuntimeException e) {
log.warning("Got DittoRuntimeException while parsing piggybackCommand <{}>: {}", piggybackCommandType,
e.getMessage());
getSender().tell(e, getSelf());
return;
}
log.info("Received PiggybackCommand: <{}> - telling to: <{}>", piggybackCommand,
command.getTargetActorSelection());
getContext().actorSelection(command.getTargetActorSelection()).forward(piggybackCommand, getContext());
} else {
final String message =
String.format("ExecutePiggybackCommand with piggybackCommand <%s> cannot be executed " +
"by this service as there is no mappingStrategy for it.", piggybackCommandType);
log.warning(message);
final JsonTypeNotParsableException typeNotMappableException =
JsonTypeNotParsableException.fromMessage(message, command.getDittoHeaders());
getSender().tell(typeNotMappableException, getSelf());
}
}