Skip to content

Commit

Permalink
[#1228] Interpret smart channel responses as "live-response"
Browse files Browse the repository at this point in the history
Signed-off-by: Yufei Cai <yufei.cai@bosch.io>
  • Loading branch information
yufei-cai committed Dec 21, 2021
1 parent 4d26f1c commit dca1a03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,10 @@ private static boolean containsOnlyTwinPersistedOrLiveResponse(final Acknowledge
private static AcknowledgementLabel getAckLabelOfResponse(final Signal<?> signal) {
// check originating signal for ack label of response
// because live commands may generate twin responses due to live timeout fallback strategy
return SignalInformationPoint.isChannelLive(signal) ? LIVE_RESPONSE : TWIN_PERSISTED;
// smart channel commands are treated as live channel commands
final var isChannelLive = SignalInformationPoint.isChannelLive(signal);
final var isChannelSmart = SignalInformationPoint.isChannelSmart(signal);
return isChannelLive || isChannelSmart ? LIVE_RESPONSE : TWIN_PERSISTED;
}

private static Duration getTimeout(final Signal<?> originatingSignal, final Duration maxTimeout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.ditto.base.model.acks.AbstractCommandAckRequestSetter;
import org.eclipse.ditto.base.model.acks.DittoAcknowledgementLabel;
import org.eclipse.ditto.things.model.signals.commands.ThingCommand;
import org.eclipse.ditto.things.model.signals.commands.query.ThingQueryCommand;

/**
* This UnaryOperator accepts a ThingCommand and checks whether its DittoHeaders should be extended by an
Expand Down Expand Up @@ -50,7 +51,7 @@ public static ThingLiveCommandAckRequestSetter getInstance() {
@Override
public boolean isApplicable(final ThingCommand<?> command) {
checkNotNull(command, "command");
return isLiveChannelCommand(command);
return isLiveChannelCommand(command) || isSmartChannelCommand(command);
}

@Override
Expand All @@ -63,4 +64,8 @@ public Class<ThingCommand<?>> getMatchedClass() {
protected boolean isBindResponseRequiredToAddingRemovingImplicitLabel() {
return true;
}

private static boolean isSmartChannelCommand(final ThingCommand<?> command) {
return command instanceof ThingQueryCommand && command.getDittoHeaders().getLiveChannelCondition().isPresent();
}
}

0 comments on commit dca1a03

Please sign in to comment.